summaryrefslogtreecommitdiff
path: root/qmake/generators/unix/unixmake2.cpp
Unidiff
Diffstat (limited to 'qmake/generators/unix/unixmake2.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/unix/unixmake2.cpp648
1 files changed, 563 insertions, 85 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
index d8a4a0d..21348a6 100644
--- a/qmake/generators/unix/unixmake2.cpp
+++ b/qmake/generators/unix/unixmake2.cpp
@@ -1,12 +1,10 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$
3** 2**
4** Definition of ________ class.
5** 3**
6** Created : 970521 4** Implementation of UnixMakefileGenerator class.
7** 5**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. 6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
9** 7**
10** This file is part of the network module of the Qt GUI Toolkit. 8** This file is part of qmake.
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
@@ -38,4 +36,5 @@
38#include "unixmake.h" 36#include "unixmake.h"
39#include "option.h" 37#include "option.h"
38#include "meta.h"
40#include <qregexp.h> 39#include <qregexp.h>
41#include <qfile.h> 40#include <qfile.h>
@@ -43,4 +42,5 @@
43#include <time.h> 42#include <time.h>
44 43
44QString mkdir_p_asstring(const QString &dir);
45 45
46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE) 46UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerator(p), init_flag(FALSE), include_deps(FALSE)
@@ -49,10 +49,34 @@ UnixMakefileGenerator::UnixMakefileGenerator(QMakeProject *p) : MakefileGenerato
49} 49}
50 50
51void
52UnixMakefileGenerator::writePrlFile(QTextStream &t)
53{
54 MakefileGenerator::writePrlFile(t);
55 // libtool support
56 if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib") { //write .la
57 if(project->isActiveConfig("compile_libtool"))
58 warn_msg(WarnLogic, "create_libtool specified with compile_libtool can lead to conflicting .la\n"
59 "formats, create_libtool has been disabled\n");
60 else
61 writeLibtoolFile();
62 }
63 // pkg-config support
64 if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib")
65 writePkgConfigFile();
66}
67
51bool 68bool
52UnixMakefileGenerator::writeMakefile(QTextStream &t) 69UnixMakefileGenerator::writeMakefile(QTextStream &t)
53{ 70{
71
54 writeHeader(t); 72 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { 73 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t" 74 t << "QMAKE = "<< (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
75 { //write the extra unix targets..
76 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
77 for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it)
78 t << *it << " ";
79 }
80 t << "all clean install distclean mocables uninstall uicables:" << "\n\t"
57 << "@echo \"Some of the required modules (" 81 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t" 82 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
@@ -74,11 +98,33 @@ UnixMakefileGenerator::writeMakefile(QTextStream &t)
74 98
75void 99void
100UnixMakefileGenerator::writeExtraVariables(QTextStream &t)
101{
102 bool first = TRUE;
103 QMap<QString, QStringList> &vars = project->variables();
104 QStringList &exports = project->variables()["QMAKE_EXTRA_UNIX_VARIABLES"];
105 for(QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) {
106 for(QStringList::Iterator exp_it = exports.begin(); exp_it != exports.end(); ++exp_it) {
107 QRegExp rx((*exp_it), FALSE, TRUE);
108 if(rx.exactMatch(it.key())) {
109 if(first) {
110 t << "\n####### Custom Variables" << endl;
111 first = FALSE;
112 }
113 t << "EXPORT_" << it.key() << " = " << it.data().join(" ") << endl;
114 }
115 }
116 }
117 if(!first)
118 t << endl;
119}
120
121void
76UnixMakefileGenerator::writeMakeParts(QTextStream &t) 122UnixMakefileGenerator::writeMakeParts(QTextStream &t)
77{ 123{
78 QString deps = fileFixify(Option::output.name()), prl; 124 QString deps = fileFixify(Option::output.name()), target_deps, prl;
79 bool do_incremental = (project->isActiveConfig("incremental") && 125 bool do_incremental = (project->isActiveConfig("incremental") &&
80 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() && 126 !project->variables()["QMAKE_INCREMENTAL"].isEmpty() &&
81 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() || 127 (!project->variables()["QMAKE_APP_FLAG"].isEmpty() ||
82 !project->isActiveConfig("staticlib"))), 128 !project->isActiveConfig("staticlib"))),
83 src_incremental=FALSE, moc_incremental=FALSE; 129 src_incremental=FALSE, moc_incremental=FALSE;
84 130
@@ -136,7 +182,12 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
136 t << "TAR = "<< var("QMAKE_TAR") << endl; 182 t << "TAR = "<< var("QMAKE_TAR") << endl;
137 t << "GZIP = " << var("QMAKE_GZIP") << endl; 183 t << "GZIP = " << var("QMAKE_GZIP") << endl;
184 if(project->isActiveConfig("compile_libtool"))
185 t << "LIBTOOL= " << var("QMAKE_LIBTOOL") << endl;
138 t << "COPY = " << var("QMAKE_COPY") << endl; 186 t << "COPY = " << var("QMAKE_COPY") << endl;
139 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl; 187 t << "COPY_FILE= " << var("QMAKE_COPY_FILE") << endl;
140 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl; 188 t << "COPY_DIR = " << var("QMAKE_COPY_DIR") << endl;
189 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
190 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
191
141 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 192 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
142 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; 193 t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
@@ -221,7 +272,23 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
221 if(do_incremental && !moc_incremental && !src_incremental) 272 if(do_incremental && !moc_incremental && !src_incremental)
222 do_incremental = FALSE; 273 do_incremental = FALSE;
274 if(!project->isEmpty("QMAKE_EXTRA_UNIX_COMPILERS")) {
275 t << "OBJCOMP = " << varList("OBJCOMP") << endl;
276 target_deps += " $(OBJCOMP)";
277
278 QStringList &comps = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
279 for(QStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) {
280 QStringList &vars = project->variables()[(*compit) + ".variables"];
281 for(QStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) {
282 QStringList vals = project->variables()[(*varit)];
283 if(!vals.isEmpty())
284 t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl;
285 }
286 }
287 }
223 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl; 288 t << "DIST = " << valList(fileFixify(project->variables()["DISTFILES"])) << endl;
224 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl; 289 t << "QMAKE_TARGET = " << var("QMAKE_ORIG_TARGET") << endl;
225 t << "DESTDIR = " << var("DESTDIR") << endl; 290 t << "DESTDIR = " << var("DESTDIR") << endl;
291 if(project->isActiveConfig("compile_libtool"))
292 t << "TARGETL= " << var("TARGET_la") << endl;
226 t << "TARGET = " << var("TARGET") << endl; 293 t << "TARGET = " << var("TARGET") << endl;
227 if(project->isActiveConfig("plugin") ) { 294 if(project->isActiveConfig("plugin") ) {
@@ -239,7 +306,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
239 } 306 }
240 } 307 }
308 writeExtraVariables(t);
241 t << endl; 309 t << endl;
242 310
243 // blasted incldues 311 // blasted includes
244 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"]; 312 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
245 QStringList::Iterator it; 313 QStringList::Iterator it;
@@ -250,5 +318,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
250 t << "first: all" << endl; 318 t << "first: all" << endl;
251 t << "####### Implicit rules" << endl << endl; 319 t << "####### Implicit rules" << endl << endl;
252 t << ".SUFFIXES: .c"; 320 t << ".SUFFIXES: .c " << Option::obj_ext;
253 QStringList::Iterator cppit; 321 QStringList::Iterator cppit;
254 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 322 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
@@ -256,6 +324,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
256 t << endl << endl; 324 t << endl << endl;
257 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) 325 for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit)
258 t << (*cppit) << ".o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; 326 t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
259 t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; 327 t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
260 328
261 if(include_deps) { 329 if(include_deps) {
@@ -279,5 +347,4 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
279 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl; 347 << "@$(CC) " << cmd << " $< | sed \"s,^\\($(*F).o\\):," << odir << "\\1:,g\" >$@" << endl << endl;
280 348
281
282 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null }; 349 QString src[] = { "SOURCES", "UICIMPLS", "SRCMOC", QString::null };
283 for(int x = 0; !src[x].isNull(); x++) { 350 for(int x = 0; !src[x].isNull(); x++) {
@@ -299,8 +366,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
299 if(!d_file.isEmpty()) { 366 if(!d_file.isEmpty()) {
300 d_file = odir + ".deps/" + d_file + ".d"; 367 d_file = odir + ".deps/" + d_file + ".d";
301 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::moc_ext + "$")); 368 QStringList deps = findDependencies((*it)).grep(QRegExp(Option::cpp_moc_ext + "$"));
302 if(!deps.isEmpty()) 369 if(!deps.isEmpty())
303 t << d_file << ": " << deps.join(" ") << endl; 370 t << d_file << ": " << deps.join(" ") << endl;
304 t << "-include " << d_file << endl; 371 t << var("QMAKE_CFLAGS_USE_PRECOMPILE") << " " << d_file << endl;
305 } 372 }
306 } 373 }
@@ -324,15 +391,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
324 QStringList::Iterator it; 391 QStringList::Iterator it;
325 for(it = l.begin(); it != l.end(); ++it) { 392 for(it = l.begin(); it != l.end(); ++it) {
326 QMakeProject proj; 393 QMakeMetaInfo libinfo;
327 if(proj.read((*it), QDir::currentDirPath()) && !proj.isEmpty("QMAKE_PRL_BUILD_DIR")) { 394 if(libinfo.readLib((*it)) && !libinfo.isEmpty("QMAKE_PRL_BUILD_DIR")) {
328 QString dir; 395 QString dir;
329 int slsh = (*it).findRev(Option::dir_sep); 396 int slsh = (*it).findRev(Option::dir_sep);
330 if(slsh != -1) 397 if(slsh != -1)
331 dir = (*it).left(slsh + 1); 398 dir = (*it).left(slsh + 1);
332 QString targ = dir + proj.first("QMAKE_PRL_TARGET"); 399 QString targ = dir + libinfo.first("QMAKE_PRL_TARGET");
333 deps += " " + targ; 400 deps += " " + targ;
334 t << targ << ":" << "\n\t" 401 t << targ << ":" << "\n\t"
335 << "@echo \"Creating '" << targ << "'\"" << "\n\t" 402 << "@echo \"Creating '" << targ << "'\"" << "\n\t"
336 << "(cd " << proj.first("QMAKE_PRL_BUILD_DIR") << ";" 403 << "(cd " << libinfo.first("QMAKE_PRL_BUILD_DIR") << ";"
337 << "$(MAKE) )" << endl; 404 << "$(MAKE) )" << endl;
338 } 405 }
@@ -393,5 +460,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
393 460
394 //real target 461 //real target
395 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps 462 t << var("TARGET") << ": " << var("PRE_TARGETDEPS") << " " << incr_deps << " " << target_deps
396 << " " << var("POST_TARGETDEPS") << "\n\t"; 463 << " " << var("POST_TARGETDEPS") << "\n\t";
397 if(!destdir.isEmpty()) 464 if(!destdir.isEmpty())
@@ -399,5 +466,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
399 if(!project->isEmpty("QMAKE_PRE_LINK")) 466 if(!project->isEmpty("QMAKE_PRE_LINK"))
400 t << var("QMAKE_PRE_LINK") << "\n\t"; 467 t << var("QMAKE_PRE_LINK") << "\n\t";
401 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(LIBS)"; 468 t << "$(LINK) $(LFLAGS) -o $(TARGET) " << incr_deps << " " << incr_objs << " $(OBJCOMP) $(LIBS)";
402 if(!project->isEmpty("QMAKE_POST_LINK")) 469 if(!project->isEmpty("QMAKE_POST_LINK"))
403 t << "\n\t" << var("QMAKE_POST_LINK"); 470 t << "\n\t" << var("QMAKE_POST_LINK");
@@ -407,11 +474,11 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
407 << endl << endl; 474 << endl << endl;
408 475
409 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " 476 t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) "
410 << var("POST_TARGETDEPS") << "\n\t"; 477 << target_deps << " " << var("POST_TARGETDEPS") << "\n\t";
411 if(!destdir.isEmpty()) 478 if(!destdir.isEmpty())
412 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 479 t << "test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
413 if(!project->isEmpty("QMAKE_PRE_LINK")) 480 if(!project->isEmpty("QMAKE_PRE_LINK"))
414 t << var("QMAKE_PRE_LINK") << "\n\t"; 481 t << var("QMAKE_PRE_LINK") << "\n\t";
415 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"; 482 t << "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)";
416 if(!project->isEmpty("QMAKE_POST_LINK")) 483 if(!project->isEmpty("QMAKE_POST_LINK"))
417 t << "\n\t" << var("QMAKE_POST_LINK"); 484 t << "\n\t" << var("QMAKE_POST_LINK");
@@ -469,11 +536,12 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
469 536
470 //real target 537 //real target
471 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " " 538 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") << " "
472 << incr_deps << " $(SUBLIBS) " << var("POST_TARGETDEPS"); 539 << incr_deps << " $(SUBLIBS) " << target_deps << " " << var("POST_TARGETDEPS");
473 } else { 540 } else {
474 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " << 541 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," ","") << " " <<
475 var("DESTDIR_TARGET") << endl << endl; 542 var("DESTDIR_TARGET") << endl << endl;
476 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS") 543 t << var("DESTDIR_TARGET") << ": " << var("PRE_TARGETDEPS")
477 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) " << var("POST_TARGETDEPS"); 544 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) $(OBJCOMP) " << target_deps
545 << " " << var("POST_TARGETDEPS");
478 } 546 }
479 if(!destdir.isEmpty()) 547 if(!destdir.isEmpty())
@@ -482,5 +550,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
482 t << "\n\t" << var("QMAKE_PRE_LINK"); 550 t << "\n\t" << var("QMAKE_PRE_LINK");
483 551
484 if(project->isActiveConfig("plugin")) { 552 if(project->isActiveConfig("compile_libtool")) {
553 t << "\n\t"
554 << var("QMAKE_LINK_SHLIB_CMD");
555 } else if(project->isActiveConfig("plugin")) {
485 t << "\n\t" 556 t << "\n\t"
486 << "-$(DEL_FILE) $(TARGET)" << "\n\t" 557 << "-$(DEL_FILE) $(TARGET)" << "\n\t"
@@ -527,5 +598,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
527 if (! project->isActiveConfig("plugin")) { 598 if (! project->isActiveConfig("plugin")) {
528 t << "staticlib: $(TARGETA)" << endl << endl; 599 t << "staticlib: $(TARGETA)" << endl << endl;
529 t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC)"; 600 t << "$(TARGETA): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(OBJCOMP)";
530 if(do_incremental) 601 if(do_incremental)
531 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)"; 602 t << " $(INCREMENTAL_OBJECTS) $(INCREMENTAL_OBJMOC)";
@@ -540,10 +611,10 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
540 } 611 }
541 } else { 612 } else {
542 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) " 613 t << "all: " << deps << " " << varGlue("ALL_DEPS",""," "," ") << var("DESTDIR") << "$(TARGET) "
543 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n" 614 << varGlue("QMAKE_AR_SUBLIBS", var("DESTDIR"), " " + var("DESTDIR"), "") << "\n\n"
544 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n"; 615 << "staticlib: " << var("DESTDIR") << "$(TARGET)" << "\n\n";
545 if(project->isEmpty("QMAKE_AR_SUBLIBS")) { 616 if(project->isEmpty("QMAKE_AR_SUBLIBS")) {
546 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS") 617 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
547 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("POST_TARGETDEPS") << "\n\t"; 618 << " $(UICDECLS) $(OBJECTS) $(OBJMOC) $(OBJCOMP) " << var("POST_TARGETDEPS") << "\n\t";
548 if(!project->isEmpty("DESTDIR")) { 619 if(!project->isEmpty("DESTDIR")) {
549 QString destdir = project->first("DESTDIR"); 620 QString destdir = project->first("DESTDIR");
@@ -556,23 +627,24 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
556 if(!project->isEmpty("QMAKE_RANLIB")) 627 if(!project->isEmpty("QMAKE_RANLIB"))
557 t << "\t" << "$(RANLIB) $(TARGET)" << "\n"; 628 t << "\t" << "$(RANLIB) $(TARGET)" << "\n";
558 if(!project->isEmpty("DESTDIR")) 629 if(!project->isEmpty("DESTDIR"))
559 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n" 630 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)" << "\n"
560 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n"; 631 << "\t" << "-$(MOVE) $(TARGET) " << var("DESTDIR") << "\n";
561 } else { 632 } else {
562 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(); 633 int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt();
563 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"], 634 QStringList objs = project->variables()["OBJECTS"] + project->variables()["OBJMOC"] +
635 project->variables()["OBJCOMP"],
564 libs = project->variables()["QMAKE_AR_SUBLIBS"]; 636 libs = project->variables()["QMAKE_AR_SUBLIBS"];
565 libs.prepend("$(TARGET)"); 637 libs.prepend("$(TARGET)");
566 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin(); 638 for(QStringList::Iterator libit = libs.begin(), objit = objs.begin();
567 libit != libs.end(); ++libit) { 639 libit != libs.end(); ++libit) {
568 QStringList build; 640 QStringList build;
569 for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++) 641 for(int cnt = 0; cnt < max_files && objit != objs.end(); ++objit, cnt++)
570 build << (*objit); 642 build << (*objit);
571 QString ar; 643 QString ar;
572 if((*libit) == "$(TARGET)") { 644 if((*libit) == "$(TARGET)") {
573 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS") 645 t << var("DESTDIR") << "$(TARGET): " << var("PRE_TARGETDEPS")
574 << " $(UICDECLS) " << var("POST_TARGETDEPS") << valList(build) << "\n\t"; 646 << " $(UICDECLS) " << var("POST_TARGETDEPS") << valList(build) << "\n\t";
575 ar = project->variables()["QMAKE_AR_CMD"].first(); 647 ar = project->variables()["QMAKE_AR_CMD"].first();
576 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)", 648 ar = ar.replace("$(OBJMOC)", "").replace("$(OBJECTS)",
577 build.join(" ")); 649 build.join(" "));
578 } else { 650 } else {
@@ -590,5 +662,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
590 if(!project->isEmpty("QMAKE_RANLIB")) 662 if(!project->isEmpty("QMAKE_RANLIB"))
591 t << "\t" << "$(RANLIB) " << (*libit) << "\n"; 663 t << "\t" << "$(RANLIB) " << (*libit) << "\n";
592 if(!project->isEmpty("DESTDIR")) 664 if(!project->isEmpty("DESTDIR"))
593 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n" 665 t << "\t" << "-$(DEL_FILE) " << var("DESTDIR") << (*libit) << "\n"
594 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n"; 666 << "\t" << "-$(MOVE) " << (*libit) << " " << var("DESTDIR") << "\n";
@@ -598,5 +670,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
598 } 670 }
599 671
600 t << "mocables: $(SRCMOC)" << endl << endl; 672 t << "mocables: $(SRCMOC)" << endl
673 << "uicables: $(UICDECLS) $(UICIMPLS)" << endl << endl;
601 674
602 if(!project->isActiveConfig("no_mocdepend")) { 675 if(!project->isActiveConfig("no_mocdepend")) {
@@ -604,13 +677,35 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
604 //moc itself shouldn't have this dependency - this is a little kludgy but it is 677 //moc itself shouldn't have this dependency - this is a little kludgy but it is
605 //better than the alternative for now. 678 //better than the alternative for now.
606 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"); 679 QString moc = project->first("QMAKE_MOC"), target = project->first("TARGET"),
680 moc_dir = "$(QTDIR)/src/moc";
681 if(!project->isEmpty("QMAKE_MOC_SRC"))
682 moc_dir = project->first("QMAKE_MOC_SRC");
607 fixEnvVariables(target); 683 fixEnvVariables(target);
608 fixEnvVariables(moc); 684 fixEnvVariables(moc);
609 if(target != moc) 685 if(target != moc)
610 t << "$(MOC): \n\t" 686 t << "$(MOC): \n\t"
611 << "( cd $(QTDIR)/src/moc ; $(MAKE) )" << endl << endl; 687 << "( cd " << moc_dir << " && $(MAKE) )" << endl << endl;
612 } 688 }
613 689
614 writeMakeQmake(t); 690 writeMakeQmake(t);
691 if(project->isEmpty("QMAKE_FAILED_REQUIREMENTS") && !project->isActiveConfig("no_autoqmake")) {
692 QString meta_files;
693 if(project->isActiveConfig("create_libtool") && project->first("TEMPLATE") == "lib" &&
694 !project->isActiveConfig("compile_libtool")) { //libtool
695 if(!meta_files.isEmpty())
696 meta_files += " ";
697 meta_files += libtoolFileName();
698 }
699 if(project->isActiveConfig("create_pc") && project->first("TEMPLATE") == "lib") { //pkg-config
700 if(!meta_files.isEmpty())
701 meta_files += " ";
702 meta_files += pkgConfigFileName();
703 }
704 if(!meta_files.isEmpty()) {
705 QStringList files = fileFixify(Option::mkfile::project_files);
706 t << meta_files << ": " << "\n\t"
707 << "@$(QMAKE) -prl " << buildArgs() << " " << files.join(" ") << endl;
708 }
709 }
615 710
616 if(!project->first("QMAKE_PKGINFO").isEmpty()) { 711 if(!project->first("QMAKE_PKGINFO").isEmpty()) {
@@ -625,5 +720,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
625 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) { 720 if(!project->first("QMAKE_INFO_PLIST").isEmpty()) {
626 QString info_plist = project->first("QMAKE_INFO_PLIST"), 721 QString info_plist = project->first("QMAKE_INFO_PLIST"),
627 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT"); 722 info_plist_out = project->first("QMAKE_INFO_PLIST_OUT");
628 QString destdir = project->first("DESTDIR"); 723 QString destdir = project->first("DESTDIR");
629 t << info_plist_out << ": " << "\n\t"; 724 t << info_plist_out << ": " << "\n\t";
@@ -631,10 +726,12 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
631 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t"; 726 t << "@test -d " << destdir << " || mkdir -p " << destdir << "\n\t";
632 t << "@$(DEL_FILE) " << info_plist_out << "\n\t" 727 t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
633 << "@cp \"" << info_plist << "\" \"" << info_plist_out << "\"" << endl; 728 << "@sed -e \"s,@ICON@,application.icns,g\" -e \"s,@EXECUTABLE@," << var("QMAKE_ORIG_TARGET")
729 << ",g\" \"" << info_plist << "\" >\"" << info_plist_out << "\"" << endl;
634 if(!project->first("RC_FILE").isEmpty()) { 730 if(!project->first("RC_FILE").isEmpty()) {
635 QString dir = destdir + "../Resources/"; 731 QString dir = destdir + "../Resources/";
636 t << dir << "application.icns:" << "\n\t" 732 t << dir << "application.icns: " << var("RC_FILE") << "\n\t"
637 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t" 733 << "@test -d " << dir << " || mkdir -p " << dir << "\n\t"
638 << "@cp " << var("RC_FILE") << " " << dir << "application.icns" << endl; 734 << "@$(DEL_FILE) " << dir << "application.icns" << "\n\t"
735 << "@$(COPY_FILE) " << var("RC_FILE") << " " << dir << "application.icns" << endl;
639 } 736 }
640 } 737 }
@@ -649,9 +746,11 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
649 if(!project->isEmpty("TRANSLATIONS")) 746 if(!project->isEmpty("TRANSLATIONS"))
650 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && "; 747 t << "$(COPY_FILE) --parents " << var("TRANSLATIONS") << " " << ddir_c << Option::dir_sep << " && ";
748 if(!project->isEmpty("IMAGES"))
749 t << "$(COPY_FILE) --parents " << var("IMAGES") << " " << ddir_c << Option::dir_sep << " && ";
651 if(!project->isEmpty("FORMS")) { 750 if(!project->isEmpty("FORMS")) {
652 QStringList &forms = project->variables()["FORMS"], ui_headers; 751 QStringList &forms = project->variables()["FORMS"], ui_headers;
653 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { 752 for(QStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) {
654 QString ui_h = fileFixify((*formit) + Option::h_ext.first()); 753 QString ui_h = fileFixify((*formit) + Option::h_ext.first());
655 if(QFile::exists(ui_h) ) 754 if(QFile::exists(ui_h) )
656 ui_headers << ui_h; 755 ui_headers << ui_h;
657 } 756 }
@@ -667,6 +766,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
667 766
668 QString clean_targets; 767 QString clean_targets;
768 t << "mocclean:" << "\n";
669 if(mocAware()) { 769 if(mocAware()) {
670 t << "mocclean:" << "\n";
671 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) { 770 if(!objMoc.isEmpty() || !srcMoc.isEmpty() || moc_incremental) {
672 if(!objMoc.isEmpty()) 771 if(!objMoc.isEmpty())
@@ -698,6 +797,6 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
698 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 797 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
699 dir += Option::dir_sep; 798 dir += Option::dir_sep;
700 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first(); 799 clean << ( dir + fi.baseName(TRUE) + Option::yacc_mod + Option::cpp_ext.first() );
701 clean << dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first(); 800 clean << ( dir + fi.baseName(TRUE) + Option::yacc_mod + Option::h_ext.first() );
702 } 801 }
703 if(!clean.isEmpty()) { 802 if(!clean.isEmpty()) {
@@ -718,5 +817,5 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
718 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep) 817 if(!dir.isEmpty() && dir.right(Option::dir_sep.length()) != Option::dir_sep)
719 dir += Option::dir_sep; 818 dir += Option::dir_sep;
720 clean << dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first(); 819 clean << ( dir + fi.baseName(TRUE) + Option::lex_mod + Option::cpp_ext.first() );
721 } 820 }
722 if(!clean.isEmpty()) { 821 if(!clean.isEmpty()) {
@@ -736,6 +835,16 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
736 835
737 t << "clean:" << clean_targets << "\n\t"; 836 t << "clean:" << clean_targets << "\n\t";
738 if(!project->isEmpty("OBJECTS")) 837 if(!project->isEmpty("OBJECTS")) {
739 t << "-$(DEL_FILE) $(OBJECTS) " << "\n\t"; 838 if(project->isActiveConfig("compile_libtool"))
839 t << "-$(LIBTOOL) --mode=clean $(DEL_FILE) $(OBJECTS)" << "\n\t";
840 else
841 t << "-$(DEL_FILE) $(OBJECTS)" << "\n\t";
842 }
843 if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
844 QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
845 QString precomph_out_dir = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep;
846 t << "-$(DEL_FILE) " << precomph_out_dir << header_prefix + "c "
847 << precomph_out_dir << header_prefix << "c++" << "\n\t";
848 }
740 if(!project->isEmpty("IMAGES")) 849 if(!project->isEmpty("IMAGES"))
741 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t"; 850 t << varGlue("QMAKE_IMAGE_COLLECTION", "\t-$(DEL_FILE) ", " ", "") << "\n\t";
@@ -763,29 +872,53 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
763 project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) 872 project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
764 t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n"; 873 t << "\t-$(DEL_FILE) -r " << destdir.section(Option::dir_sep, 0, -4) << "\n";
874 else if(project->isActiveConfig("compile_libtool"))
875 t << "\t-$(LIBTOOL) --mode=clean $(DEL_FILE) " << "$(TARGET)" << "\n";
765 else 876 else
766 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n"; 877 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET)" << " " << "$(TARGET)" << "\n";
767 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() && 878 if(!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty() &&
768 !project->isActiveConfig("plugin")) 879 !project->isActiveConfig("plugin") && !project->isActiveConfig("compile_libtool"))
769 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " 880 t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) "
770 << destdir << "$(TARGET2) $(TARGETA)" << "\n"; 881 << destdir << "$(TARGET2) $(TARGETA)" << "\n";
771 t << endl << endl; 882 t << endl << endl;
772 883
773 if ( !project->isEmpty("PRECOMPH") ) { 884 if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER") ) {
885 QString precomph = fileFixify(project->first("PRECOMPILED_HEADER"));
886 t << "###### Prefix headers" << endl;
887 QString comps[] = { "C", "CXX", QString::null };
888 for(int i = 0; !comps[i].isNull(); i++) {
889 QString flags = var("QMAKE_" + comps[i] + "FLAGS_PRECOMPILE");
890 flags += " $(" + comps[i] + "FLAGS)";
891
892 QString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
893 QString outdir = project->first("QMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep, outfile = outdir;
894 QString compiler;
895 if(comps[i] == "C") {
896 outfile += header_prefix + "c";
897 compiler = "$(CC) ";
898 } else {
899 outfile += header_prefix + "c++";
900 compiler = "$(CXX) ";
901 }
902 t << outfile << ": " << precomph << " " << findDependencies(precomph).join(" \\\n\t\t")
903 << "\n\t" << "test -d " << outdir << " || mkdir -p " << outdir
904 << "\n\t" << compiler << flags << " $(INCPATH) " << precomph << " -o " << outfile << endl << endl;
905 }
906 }
907 if(!project->isEmpty("ALLMOC_HEADER")) {
774 QString outdir = project->first("MOC_DIR"); 908 QString outdir = project->first("MOC_DIR");
775 QString qt_dot_h = Option::fixPathToLocalOS(project->first("PRECOMPH")); 909 QString precomph = fileFixify(project->first("ALLMOC_HEADER"));
776 t << "###### Combined headers" << endl << endl; 910 t << "###### Combined headers" << endl << endl
777 //XXX 911 << outdir << "allmoc.cpp: " << precomph << " "
778 t << outdir << "allmoc.cpp: " << qt_dot_h << " "
779 << varList("HEADERS_ORIG") << "\n\t" 912 << varList("HEADERS_ORIG") << "\n\t"
780 << "echo '#include \"" << qt_dot_h << "\"' >" << outdir << "allmoc.cpp" << "\n\t" 913 << "echo '#include \"" << precomph << "\"' >" << outdir << "allmoc.cpp" << "\n\t"
781 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h " 914 << "$(CXX) -E -DQT_MOC_CPP -DQT_NO_STL $(CXXFLAGS) $(INCPATH) >" << outdir << "allmoc.h "
782 << outdir << "allmoc.cpp" << "\n\t" 915 << outdir << "allmoc.cpp" << "\n\t"
783 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t" 916 << "$(MOC) -o " << outdir << "allmoc.cpp " << outdir << "allmoc.h" << "\n\t"
784 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \"" 917 << "perl -pi -e 's{#include \"allmoc.h\"}{#define QT_H_CPP\\n#include \""
785 << qt_dot_h << "\"}' " << outdir << "allmoc.cpp" << "\n\t" 918 << precomph << "\"}' " << outdir << "allmoc.cpp" << "\n\t"
786 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl; 919 << "$(DEL_FILE) " << outdir << "allmoc.h" << endl << endl;
787 } 920 }
788 921
789 // blasted user defined targets 922 // user defined targets
790 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"]; 923 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
791 for(it = qut.begin(); it != qut.end(); ++it) { 924 for(it = qut.begin(); it != qut.end(); ++it) {
@@ -801,7 +934,57 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
801 deps += " " + dep; 934 deps += " " + dep;
802 } 935 }
936 if(project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1)
937 deps += QString(" ") + "FORCE";
803 t << targ << ":" << deps << "\n\t" 938 t << targ << ":" << deps << "\n\t"
804 << cmd << endl << endl; 939 << cmd << endl << endl;
805 } 940 }
941 // user defined compilers
942 QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
943 for(it = quc.begin(); it != quc.end(); ++it) {
944 QString tmp_out = project->variables()[(*it) + ".output"].first();
945 QString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
946 QString tmp_dep = project->variables()[(*it) + ".depends"].join(" ");
947 QStringList &vars = project->variables()[(*it) + ".variables"];
948 if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
949 continue;
950 QStringList &tmp = project->variables()[(*it) + ".input"];
951 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
952 QStringList &inputs = project->variables()[(*it2)];
953 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
954 QFileInfo fi(Option::fixPathToLocalOS((*input)));
955 QString in = Option::fixPathToTargetOS((*input), FALSE),
956 out = tmp_out, cmd = tmp_cmd, deps;
957 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
958 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
959 cmd.replace("${QMAKE_FILE_BASE}", fi.baseName());
960 cmd.replace("${QMAKE_FILE_OUT}", out);
961 cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
962 for(QStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3)
963 cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
964 if(!tmp_dep.isEmpty()) {
965 char buff[256];
966 QString dep_cmd = tmp_dep;
967 dep_cmd.replace("${QMAKE_FILE_NAME}", fi.fileName());
968 if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) {
969 while(!feof(proc)) {
970 int read_in = int(fread(buff, 1, 255, proc));
971 if(!read_in)
972 break;
973 int l = 0;
974 for(int i = 0; i < read_in; i++) {
975 if(buff[i] == '\n' || buff[i] == ' ') {
976 deps += " " + QCString(buff+l, (i - l) + 1);
977 l = i;
978 }
979 }
980 }
981 fclose(proc);
982 }
983 }
984 t << out << ": " << in << deps << "\n\t"
985 << cmd << endl << endl;
986 }
987 }
988 }
806 t <<"FORCE:" << endl << endl; 989 t <<"FORCE:" << endl << endl;
807} 990}
@@ -815,4 +998,10 @@ void
815UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct) 998UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
816{ 999{
1000 // blasted includes
1001 QStringList &qeui = project->variables()["QMAKE_EXTRA_UNIX_INCLUDES"];
1002 for(QStringList::Iterator qeui_it = qeui.begin(); qeui_it != qeui.end(); ++qeui_it)
1003 t << "include " << (*qeui_it) << endl;
1004 writeExtraVariables(t);
1005
817 QPtrList<SubDir> subdirs; 1006 QPtrList<SubDir> subdirs;
818 { 1007 {
@@ -833,4 +1022,6 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
833 } 1022 }
834 } else { 1023 } else {
1024 if(!file.isEmpty())
1025 sd->profile = file.section(Option::dir_sep, -1) + ".pro";
835 sd->directory = file; 1026 sd->directory = file;
836 } 1027 }
@@ -858,6 +1049,10 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
858 t << "QMAKE =" << var("QMAKE") << endl; 1049 t << "QMAKE =" << var("QMAKE") << endl;
859 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 1050 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
1051 t << "CHK_DIR_EXISTS= " << var("QMAKE_CHK_DIR_EXISTS") << endl;
1052 t << "MKDIR = " << var("QMAKE_MKDIR") << endl;
1053 t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl;
1054 t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
860 t << "SUBTARGETS ="; // subdirectory targets are sub-directory 1055 t << "SUBTARGETS ="; // subdirectory targets are sub-directory
861 for( it.toFirst(); it.current(); ++it) 1056 for( it.toFirst(); it.current(); ++it)
862 t << " \\\n\t\t" << it.current()->target; 1057 t << " \\\n\t\t" << it.current()->target;
863 t << endl << endl; 1058 t << endl << endl;
@@ -875,6 +1070,8 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
875 t << mkfile << ": " << "\n\t"; 1070 t << mkfile << ": " << "\n\t";
876 if(have_dir) 1071 if(have_dir)
877 t << "cd " << (*it)->directory << " && "; 1072 t << mkdir_p_asstring((*it)->directory) << "\n\t"
878 t << "$(QMAKE) " << (*it)->profile << buildArgs() << out << endl; 1073 << "cd " << (*it)->directory << " && ";
1074 QString profile = fileFixify((*it)->profile, (*it)->directory, (*it)->directory);
1075 t << "$(QMAKE) " << profile << buildArgs() << out << endl;
879 //actually compile 1076 //actually compile
880 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t"; 1077 t << (*it)->target << ": " << mkfile << " FORCE" << "\n\t";
@@ -888,5 +1085,5 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
888 QString tar = it.current()->target; 1085 QString tar = it.current()->target;
889 ++it; 1086 ++it;
890 if (it.current()) 1087 if (it.current())
891 t << it.current()->target << ": " << tar << endl; 1088 t << it.current()->target << ": " << tar << endl;
892 } 1089 }
@@ -897,5 +1094,6 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
897 1094
898 if(project->isEmpty("SUBDIRS")) { 1095 if(project->isEmpty("SUBDIRS")) {
899 t << "all qmake_all distclean install uiclean mocclean lexclean yaccclean clean: FORCE" << endl; 1096 t << "all qmake_all distclean uicables mocables install_subdirs uninstall_subdirs"
1097 << " uiclean mocclean lexclean yaccclean clean " << var("SUBDIR_TARGETS") << ": FORCE" << endl;
900 } else { 1098 } else {
901 t << "all: $(SUBTARGETS)" << endl; 1099 t << "all: $(SUBTARGETS)" << endl;
@@ -911,9 +1109,10 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
911 if(!(*it)->directory.isEmpty()) 1109 if(!(*it)->directory.isEmpty())
912 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; "; 1110 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
913 t << "grep \"^qmake_all:\" " << (*it)->makefile 1111 t << "grep \"^qmake_all:\" " << (*it)->makefile
914 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true"; 1112 << " && $(MAKE) -f " << (*it)->makefile << " qmake_all" << "; ) || true";
915 } 1113 }
916 t << endl; 1114 t << endl;
917 t << "clean uninstall install uiclean mocclean lexclean yaccclean: qmake_all FORCE"; 1115 t << "clean uicables mocables uiclean mocclean lexclean yaccclean "
1116 << var("SUBDIR_TARGETS") << ": qmake_all FORCE";
918 for( it.toFirst(); it.current(); ++it) { 1117 for( it.toFirst(); it.current(); ++it) {
919 t << "\n\t ( "; 1118 t << "\n\t ( ";
@@ -923,4 +1122,20 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
923 } 1122 }
924 t << endl; 1123 t << endl;
1124 t << "uninstall_subdirs: qmake_all FORCE";
1125 for( it.toFirst(); it.current(); ++it) {
1126 t << "\n\t ( ";
1127 if(!(*it)->directory.isEmpty())
1128 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
1129 t << "$(MAKE) -f " << (*it)->makefile << " uninstall" << "; ) || true";
1130 }
1131 t << endl;
1132 t << "install_subdirs: qmake_all FORCE";
1133 for( it.toFirst(); it.current(); ++it) {
1134 t << "\n\t ( ";
1135 if(!(*it)->directory.isEmpty())
1136 t << "[ -d " << (*it)->directory << " ] && cd " << (*it)->directory << " ; ";
1137 t << "$(MAKE) -f " << (*it)->makefile << " install" << "; ) || true";
1138 }
1139 t << endl;
925 t << "distclean: qmake_all FORCE"; 1140 t << "distclean: qmake_all FORCE";
926 for( it.toFirst(); it.current(); ++it) { 1141 for( it.toFirst(); it.current(); ++it) {
@@ -932,4 +1147,29 @@ UnixMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
932 t << endl << endl; 1147 t << endl << endl;
933 } 1148 }
1149
1150 //installations
1151 project->variables()["INSTALLDEPS"] += "install_subdirs";
1152 project->variables()["UNINSTALLDEPS"] += "uninstall_subdirs";
1153 writeInstalls(t, "INSTALLS");
1154
1155 // user defined targets
1156 QStringList &qut = project->variables()["QMAKE_EXTRA_UNIX_TARGETS"];
1157 for(QStringList::Iterator qut_it = qut.begin(); qut_it != qut.end(); ++qut_it) {
1158 QString targ = var((*qut_it) + ".target"),
1159 cmd = var((*qut_it) + ".commands"), deps;
1160 if(targ.isEmpty())
1161 targ = (*qut_it);
1162 QStringList &deplist = project->variables()[(*qut_it) + ".depends"];
1163 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
1164 QString dep = var((*dep_it) + ".target");
1165 if(dep.isEmpty())
1166 dep = (*dep_it);
1167 deps += " " + dep;
1168 }
1169 if(project->variables()[(*qut_it) + ".CONFIG"].findIndex("phony") != -1)
1170 deps += QString(" ") + "FORCE";
1171 t << targ << ":" << deps << "\n\t"
1172 << cmd << endl << endl;
1173 }
934 t <<"FORCE:" << endl << endl; 1174 t <<"FORCE:" << endl << endl;
935} 1175}
@@ -968,18 +1208,24 @@ void UnixMakefileGenerator::init2()
968 } else { 1208 } else {
969 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a"); 1209 project->variables()["TARGETA"].append(project->first("DESTDIR") + "lib" + project->first("TARGET") + ".a");
1210 if( project->isActiveConfig("compile_libtool") )
1211 project->variables()["TARGET_la"] = project->first("DESTDIR") + "lib" + project->first("TARGET") + Option::libtool_ext;
1212
970 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() ) 1213 if ( !project->variables()["QMAKE_AR_CMD"].isEmpty() )
971 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)"); 1214 project->variables()["QMAKE_AR_CMD"].first().replace("(TARGET)","(TARGETA)");
972 else 1215 else
973 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)"); 1216 project->variables()["QMAKE_AR_CMD"].append("$(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)");
974 if( project->isActiveConfig("plugin") ) { 1217 if( project->isActiveConfig("compile_libtool") ) {
1218 project->variables()["TARGET"] = project->variables()["TARGET_la"];
1219 } else if( project->isActiveConfig("plugin") ) {
975 project->variables()["TARGET_x.y.z"].append("lib" + 1220 project->variables()["TARGET_x.y.z"].append("lib" +
976 project->first("TARGET") + "." + project->first("QMAKE_EXTENSION_SHLIB")); 1221 project->first("TARGET") + "." +
1222 project->first("QMAKE_EXTENSION_PLUGIN"));
977 if(project->isActiveConfig("lib_version_first")) 1223 if(project->isActiveConfig("lib_version_first"))
978 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1224 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
979 project->first("VER_MAJ") + "." + 1225 project->first("VER_MAJ") + "." +
980 project->first("QMAKE_EXTENSION_SHLIB")); 1226 project->first("QMAKE_EXTENSION_PLUGIN"));
981 else 1227 else
982 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1228 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
983 project->first("QMAKE_EXTENSION_SHLIB") + 1229 project->first("QMAKE_EXTENSION_PLUGIN") +
984 "." + project->first("VER_MAJ")); 1230 "." + project->first("VER_MAJ"));
985 1231
@@ -990,8 +1236,8 @@ void UnixMakefileGenerator::init2()
990 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl"); 1236 project->variables()["TARGET_"].append("lib" + project->first("TARGET") + ".sl");
991 if(project->isActiveConfig("lib_version_first")) 1237 if(project->isActiveConfig("lib_version_first"))
992 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." + 1238 project->variables()["TARGET_x"].append("lib" + project->first("VER_MAJ") + "." +
993 project->first("TARGET")); 1239 project->first("TARGET"));
994 else 1240 else
995 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." + 1241 project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
996 project->first("VER_MAJ")); 1242 project->first("VER_MAJ"));
997 project->variables()["TARGET"] = project->variables()["TARGET_x"]; 1243 project->variables()["TARGET"] = project->variables()["TARGET_x"];
@@ -1076,20 +1322,42 @@ void UnixMakefileGenerator::init2()
1076 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() ) 1322 if ( project->variables()["QMAKE_LINK_SHLIB_CMD"].isEmpty() )
1077 project->variables()["QMAKE_LINK_SHLIB_CMD"].append( 1323 project->variables()["QMAKE_LINK_SHLIB_CMD"].append(
1078 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)"); 1324 "$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) $(OBJCOMP)");
1079 } 1325 }
1080 if(project->isEmpty("QMAKE_SYMBOLIC_LINK")) 1326 if(project->isEmpty("QMAKE_SYMBOLIC_LINK"))
1081 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf"); 1327 project->variables()["QMAKE_SYMBOLIC_LINK"].append("ln -sf");
1082 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { 1328 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
1083 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHAPP"]; 1329 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_APP"];
1330 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_APP"];
1331 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_APP"];
1084 } else if ( project->isActiveConfig("dll") ) { 1332 } else if ( project->isActiveConfig("dll") ) {
1085 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"]; 1333 if( !project->isActiveConfig("plugin") || !project->isActiveConfig("plugin_no_share_shlib_cflags")) {
1086 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"]; 1334 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_SHLIB"];
1335 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_SHLIB"];
1336 }
1087 if ( project->isActiveConfig("plugin") ) { 1337 if ( project->isActiveConfig("plugin") ) {
1338 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_PLUGIN"];
1339 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_PLUGIN"];
1088 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"]; 1340 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_PLUGIN"];
1089 if( !project->isActiveConfig("plugin_no_soname") ) 1341 if( project->isActiveConfig("plugin_with_soname") && !project->isActiveConfig("compile_libtool"))
1090 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1342 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1091 } else { 1343 } else {
1092 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"]; 1344 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SHLIB"];
1093 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"]; 1345 if(!project->isEmpty("QMAKE_LFLAGS_COMPAT_VERSION")) {
1346 if(project->isEmpty("COMPAT_VERSION"))
1347 project->variables()["QMAKE_LFLAGS"] += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION") +
1348 project->first("VER_MAJ") + "." +
1349 project->first("VER_MIN"));
1350 else
1351 project->variables()["QMAKE_LFLAGS"] += QString(project->first("QMAKE_LFLAGS_COMPAT_VERSION") +
1352 project->first("COMPATIBILITY_VERSION"));
1353 }
1354 if(!project->isEmpty("QMAKE_LFLAGS_VERSION")) {
1355 project->variables()["QMAKE_LFLAGS"] += QString(project->first("QMAKE_LFLAGS_VERSION") +
1356 project->first("VER_MAJ") + "." +
1357 project->first("VER_MIN") + "." +
1358 project->first("VER_PAT"));
1359 }
1360 if(!project->isActiveConfig("compile_libtool"))
1361 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_SONAME"];
1094 } 1362 }
1095 QString destdir = project->first("DESTDIR"); 1363 QString destdir = project->first("DESTDIR");
@@ -1108,3 +1376,213 @@ void UnixMakefileGenerator::init2()
1108 } 1376 }
1109 } 1377 }
1378 QStringList &quc = project->variables()["QMAKE_EXTRA_UNIX_COMPILERS"];
1379 for(QStringList::Iterator it = quc.begin(); it != quc.end(); ++it) {
1380 QString tmp_out = project->variables()[(*it) + ".output"].first();
1381 if(tmp_out.isEmpty())
1382 continue;
1383 QStringList &tmp = project->variables()[(*it) + ".input"];
1384 for(QStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
1385 QStringList &inputs = project->variables()[(*it2)];
1386 for(QStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
1387 QFileInfo fi(Option::fixPathToLocalOS((*input)));
1388 QString in = Option::fixPathToTargetOS((*input), FALSE),
1389 out = tmp_out;
1390 out.replace("${QMAKE_FILE_BASE}", fi.baseName());
1391 out.replace("${QMAKE_FILE_NAME}", fi.fileName());
1392 if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1)
1393 project->variables()["OBJCOMP"] += out;
1394 }
1395 }
1396 }
1397}
1398
1399QString
1400UnixMakefileGenerator::libtoolFileName()
1401{
1402 QString ret = var("TARGET");
1403 int slsh = ret.findRev(Option::dir_sep);
1404 if(slsh != -1)
1405 ret = ret.right(ret.length() - slsh);
1406 int dot = ret.find('.');
1407 if(dot != -1)
1408 ret = ret.left(dot);
1409 ret += Option::libtool_ext;
1410 if(!project->isEmpty("DESTDIR"))
1411 ret.prepend(var("DESTDIR"));
1412 return ret;
1413}
1414
1415void
1416UnixMakefileGenerator::writeLibtoolFile()
1417{
1418 QString fname = libtoolFileName(), lname = fname;
1419 int slsh = lname.findRev(Option::dir_sep);
1420 if(slsh != -1)
1421 lname = lname.right(lname.length() - slsh - 1);
1422 QFile ft(fname);
1423 if(!ft.open(IO_WriteOnly))
1424 return;
1425 project->variables()["ALL_DEPS"].append(fname);
1426
1427 QTextStream t(&ft);
1428 t << "# " << lname << " - a libtool library file\n";
1429 time_t now = time(NULL);
1430 t << "# Generated by qmake/libtool (" << qmake_version() << ") (Qt "
1431 << QT_VERSION_STR << ") on: " << ctime(&now) << "\n";
1432
1433 t << "# The name that we can dlopen(3).\n"
1434 << "dlname='" << var(project->isActiveConfig("plugin") ? "TARGET" : "TARGET_x")
1435 << "'\n\n";
1436
1437 t << "# Names of this library.\n";
1438 t << "library_names='";
1439 if(project->isActiveConfig("plugin")) {
1440 t << var("TARGET");
1441 } else {
1442 if (project->isEmpty("QMAKE_HPUX_SHLIB"))
1443 t << var("TARGET_x.y.z") << " ";
1444 t << var("TARGET_x") << " " << var("TARGET_");
1445 }
1446 t << "'\n\n";
1447
1448 t << "# The name of the static archive.\n"
1449 << "old_library='" << lname.left(lname.length()-Option::libtool_ext.length()) << ".a'\n\n";
1450
1451 t << "# Libraries that this one depends upon.\n";
1452 QStringList libs;
1453 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
1454 libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"];
1455 else
1456 libs << "QMAKE_LIBS"; //obvious one
1457 t << "dependency_libs='";
1458 for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
1459 t << project->variables()[(*it)].join(" ") << " ";
1460 t << "'\n\n";
1461
1462 t << "# Version information for " << lname << "\n";
1463 int maj = project->first("VER_MAJ").toInt();
1464 int min = project->first("VER_MIN").toInt();
1465 int pat = project->first("VER_PAT").toInt();
1466 t << "current=" << (10*maj + min) << "\n" // best I can think of
1467 << "age=0\n"
1468 << "revision=" << pat << "\n\n";
1469
1470 t << "# Is this an already installed library.\n"
1471 "installed=yes\n\n"; // ###
1472
1473 t << "# Files to dlopen/dlpreopen.\n"
1474 "dlopen=''\n"
1475 "dlpreopen=''\n\n";
1476
1477 QString install_dir = project->first("target.path");
1478 if(install_dir.isEmpty())
1479 install_dir = project->first("DESTDIR");
1480 t << "# Directory that this library needs to be installed in:\n"
1481 "libdir='" << Option::fixPathToTargetOS(install_dir, FALSE) << "'\n";
1482}
1483
1484QString
1485UnixMakefileGenerator::pkgConfigFileName()
1486{
1487 QString ret = var("TARGET");
1488 int slsh = ret.findRev(Option::dir_sep);
1489 if(slsh != -1)
1490 ret = ret.right(ret.length() - slsh);
1491 if(ret.startsWith("lib"))
1492 ret = ret.mid(3);
1493 int dot = ret.find('.');
1494 if(dot != -1)
1495 ret = ret.left(dot);
1496 ret += Option::pkgcfg_ext;
1497 if(!project->isEmpty("DESTDIR")) {
1498 ret.prepend(var("DESTDIR"));
1499 ret = Option::fixPathToLocalOS(fileFixify(ret,QDir::currentDirPath(), Option::output_dir));
1500 }
1501 return ret;
1502}
1503
1504QString
1505UnixMakefileGenerator::pkgConfigPrefix() const
1506{
1507 if(!project->isEmpty("QMAKE_PKGCONFIG_PREFIX"))
1508 return project->first("QMAKE_PKGCONFIG_PREFIX");
1509 return qInstallPath();
1510}
1511
1512QString
1513UnixMakefileGenerator::pkgConfigFixPath(QString path) const
1514{
1515 QString prefix = pkgConfigPrefix();
1516 if(path.startsWith(prefix))
1517 path = path.replace(prefix, "${prefix}");
1518 return path;
1519}
1520
1521void
1522UnixMakefileGenerator::writePkgConfigFile() // ### does make sense only for libqt so far
1523{
1524 QString fname = pkgConfigFileName(), lname = fname;
1525 int slsh = lname.findRev(Option::dir_sep);
1526 if(slsh != -1)
1527 lname = lname.right(lname.length() - slsh - 1);
1528 QFile ft(fname);
1529 if(!ft.open(IO_WriteOnly))
1530 return;
1531 project->variables()["ALL_DEPS"].append(fname);
1532 QTextStream t(&ft);
1533
1534 QString prefix = pkgConfigPrefix();
1535 QString libDir = project->first("QMAKE_PKGCONFIG_LIBDIR");
1536 if(libDir.isEmpty())
1537 libDir = prefix + "/lib";
1538 QString includeDir = project->first("QMAKE_PKGCONFIG_INCDIR");
1539 if(includeDir.isEmpty())
1540 includeDir = prefix + "/include";
1541
1542 t << "prefix=" << prefix << endl;
1543 t << "exec_prefix=${prefix}\n"
1544 << "libdir=" << pkgConfigFixPath(libDir) << "\n"
1545 << "includedir=" << pkgConfigFixPath(includeDir) << endl;
1546 // non-standard entry. Provides useful info normally only
1547 // contained in the internal .qmake.cache file
1548 t << varGlue("CONFIG", "qt_config=", " ", "") << endl << endl;
1549
1550 t << "Name: Qt" << endl;
1551 QString desc = project->first("QMAKE_PKGCONFIG_DESCRIPTION");
1552 if(desc.isEmpty()) {
1553 desc = project->first("TARGET").lower();
1554 desc.replace(0, 1, desc[0].upper());
1555 if(project->first("TEMPLATE") == "lib") {
1556 if(project->isActiveConfig("plugin"))
1557 desc += " Plugin";
1558 else
1559 desc += " Library";
1560 } else if(project->first("TEMPLATE") == "app") {
1561 desc += " Application";
1562 }
1563 }
1564 t << "Description: " << desc << endl;
1565 t << "Version: " << project->first("VERSION") << endl;
1566
1567 // libs
1568 QStringList libs;
1569 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
1570 libs = project->variables()["QMAKE_INTERNAL_PRL_LIBS"];
1571 else
1572 libs << "QMAKE_LIBS"; //obvious one
1573 if(project->isActiveConfig("thread"))
1574 libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread?
1575 t << "Libs: -L${libdir} -l" << lname.left(lname.length()-Option::libtool_ext.length()) << " ";
1576 for(QStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
1577 t << project->variables()[(*it)].join(" ") << " ";
1578 t << endl;
1579
1580 // flags
1581 // ### too many
1582 t << "Cflags: "
1583 // << var("QMAKE_CXXFLAGS") << " "
1584 << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
1585 << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ")
1586 // << varGlue("DEFINES","-D"," -D"," ")
1587 << " -I${includedir}";
1110} 1588}