summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/qmake/generators/unix/unixmake.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tqtinterface/qt4/qmake/generators/unix/unixmake.cpp')
-rw-r--r--tqtinterface/qt4/qmake/generators/unix/unixmake.cpp901
1 files changed, 0 insertions, 901 deletions
diff --git a/tqtinterface/qt4/qmake/generators/unix/unixmake.cpp b/tqtinterface/qt4/qmake/generators/unix/unixmake.cpp
deleted file mode 100644
index 82d7ef6..0000000
--- a/tqtinterface/qt4/qmake/generators/unix/unixmake.cpp
+++ /dev/null
@@ -1,901 +0,0 @@
-/****************************************************************************
-**
-** Implementation of UnixMakefileGenerator class.
-**
-** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
-**
-** This file is part of qmake.
-**
-** This file may be used under the terms of the GNU General
-** Public License versions 2.0 or 3.0 as published by the Free
-** Software Foundation and appearing in the files LICENSE.GPL2
-** and LICENSE.GPL3 included in the packaging of this file.
-** Alternatively you may (at your option) use any later version
-** of the GNU General Public License if such license has been
-** publicly approved by Trolltech ASA (or its successors, if any)
-** and the KDE Free TQt Foundation.
-**
-** Please review the following information to ensure GNU General
-** Public Licensing requirements will be met:
-** http://trolltech.com/products/qt/licenses/licensing/opensource/.
-** If you are unsure which license is appropriate for your use, please
-** review the following information:
-** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
-** or contact the sales department at sales@trolltech.com.
-**
-** This file may be used under the terms of the Q Public License as
-** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
-** included in the packaging of this file. Licensees holding valid TQt
-** Commercial licenses may use this file in accordance with the TQt
-** Commercial License Agreement provided with the Software.
-**
-** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
-** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
-** herein.
-**
-**********************************************************************/
-
-#include "unixmake.h"
-#include "option.h"
-#include <tqregexp.h>
-#include <tqfile.h>
-#include <tqdict.h>
-#include <tqdir.h>
-#include <time.h>
-
-
-void
-UnixMakefileGenerator::init()
-{
- if(init_flag)
- return;
- init_flag = TRUE;
-
- if(!project->isEmpty("TQMAKE_FAILED_RETQUIREMENTS")) /* no point */
- return;
-
- TQStringList &configs = project->variables()["CONFIG"];
- /* this should probably not be here, but I'm using it to wrap the .t files */
- if(project->first("TEMPLATE") == "app")
- project->variables()["TQMAKE_APP_FLAG"].append("1");
- else if(project->first("TEMPLATE") == "lib")
- project->variables()["TQMAKE_LIB_FLAG"].append("1");
- else if(project->first("TEMPLATE") == "subdirs") {
- MakefileGenerator::init();
- if(project->isEmpty("MAKEFILE"))
- project->variables()["MAKEFILE"].append("Makefile");
- if(project->isEmpty("TQMAKE"))
- project->variables()["TQMAKE"].append("qmake");
- if(project->variables()["TQMAKE_INTERNAL_TQMAKE_DEPS"].findIndex("qmake_all") == -1)
- project->variables()["TQMAKE_INTERNAL_TQMAKE_DEPS"].append("qmake_all");
- return; /* subdirs is done */
- }
-
- if( project->isEmpty("TQMAKE_EXTENSION_SHLIB") ) {
- if ( project->isEmpty("TQMAKE_CYGWIN_SHLIB") ) {
- project->variables()["TQMAKE_EXTENSION_SHLIB"].append( "so" );
- } else {
- project->variables()["TQMAKE_EXTENSION_SHLIB"].append( "dll" );
- }
- }
- if( project->isEmpty("TQMAKE_CFLAGS_PRECOMPILE"))
- project->variables()["TQMAKE_CFLAGS_PRECOMPILE"].append("-x c-header -c");
- if( project->isEmpty("TQMAKE_CXXFLAGS_PRECOMPILE"))
- project->variables()["TQMAKE_CXXFLAGS_PRECOMPILE"].append("-x c++-header -c");
- if( project->isEmpty("TQMAKE_CFLAGS_USE_PRECOMPILE"))
- project->variables()["TQMAKE_CFLAGS_USE_PRECOMPILE"].append("-include");
- if( project->isEmpty("TQMAKE_EXTENSION_PLUGIN") )
- project->variables()["TQMAKE_EXTENSION_PLUGIN"].append(project->first("TQMAKE_EXTENSION_SHLIB"));
- if( project->isEmpty("TQMAKE_COPY_FILE") )
- project->variables()["TQMAKE_COPY_FILE"].append( "$(COPY)" );
- if( project->isEmpty("TQMAKE_COPY_DIR") )
- project->variables()["TQMAKE_COPY_DIR"].append( "$(COPY) -R" );
- if( project->isEmpty("TQMAKE_INSTALL_FILE") )
- project->variables()["TQMAKE_INSTALL_FILE"].append( "$(COPY_FILE)" );
- if( project->isEmpty("TQMAKE_INSTALL_DIR") )
- project->variables()["TQMAKE_INSTALL_DIR"].append( "$(COPY_DIR)" );
- if( project->isEmpty("TQMAKE_LIBTOOL") )
- project->variables()["TQMAKE_LIBTOOL"].append( "libtool --silent" );
- //If the TARGET looks like a path split it into DESTDIR and the resulting TARGET
- if(!project->isEmpty("TARGET")) {
- TQString targ = project->first("TARGET");
- int slsh = TQMAX(targ.findRev('/'), targ.findRev(Option::dir_sep));
- if(slsh != -1) {
- if(project->isEmpty("DESTDIR"))
- project->values("DESTDIR").append("");
- else if(project->first("DESTDIR").right(1) != Option::dir_sep)
- project->variables()["DESTDIR"] = TQString(project->first("DESTDIR") + Option::dir_sep);
- project->variables()["DESTDIR"] = TQString(project->first("DESTDIR") + targ.left(slsh+1));
- project->variables()["TARGET"] = TQString(targ.mid(slsh+1));
- }
- }
-
- project->variables()["TQMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
- project->variables()["TQMAKE_ORIG_DESTDIR"] = project->variables()["DESTDIR"];
-
- bool is_qt = (project->first("TARGET") == "tqt" || project->first("TARGET") == "tqte" ||
- project->first("TARGET") == "tqt-mt" || project->first("TARGET") == "tqte-mt");
- bool extern_libs = !project->isEmpty("TQMAKE_APP_FLAG") ||
- (!project->isEmpty("TQMAKE_LIB_FLAG") &&
- project->isActiveConfig("dll")) || is_qt;
- project->variables()["TQMAKE_LIBS"] += project->variables()["LIBS"];
- if ( (!project->isEmpty("TQMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib") ) ||
- (project->isActiveConfig("qt") && project->isActiveConfig( "plugin" ) )) {
- if(configs.findIndex("dll") == -1) configs.append("dll");
- } else if ( !project->isEmpty("TQMAKE_APP_FLAG") || project->isActiveConfig("dll") ) {
- configs.remove("staticlib");
- }
- if ( project->isActiveConfig("warn_off") ) {
- project->variables()["TQMAKE_CFLAGS"] += project->variables()["TQMAKE_CFLAGS_WARN_OFF"];
- project->variables()["TQMAKE_CXXFLAGS"] += project->variables()["TQMAKE_CXXFLAGS_WARN_OFF"];
- } else if ( project->isActiveConfig("warn_on") ) {
- project->variables()["TQMAKE_CFLAGS"] += project->variables()["TQMAKE_CFLAGS_WARN_ON"];
- project->variables()["TQMAKE_CXXFLAGS"] += project->variables()["TQMAKE_CXXFLAGS_WARN_ON"];
- }
- if ( project->isActiveConfig("debug") ) {
- project->variables()["TQMAKE_CFLAGS"] += project->variables()["TQMAKE_CFLAGS_DEBUG"];
- project->variables()["TQMAKE_CXXFLAGS"] += project->variables()["TQMAKE_CXXFLAGS_DEBUG"];
- project->variables()["TQMAKE_LFLAGS"] += project->variables()["TQMAKE_LFLAGS_DEBUG"];
- } else {
- project->variables()["TQMAKE_CFLAGS"] += project->variables()["TQMAKE_CFLAGS_RELEASE"];
- project->variables()["TQMAKE_CXXFLAGS"] += project->variables()["TQMAKE_CXXFLAGS_RELEASE"];
- project->variables()["TQMAKE_LFLAGS"] += project->variables()["TQMAKE_LFLAGS_RELEASE"];
- }
- if(!project->isEmpty("TQMAKE_INCREMENTAL"))
- project->variables()["TQMAKE_LFLAGS"] += project->variables()["TQMAKE_LFLAGS_INCREMENTAL"];
- else if(!project->isEmpty("TQMAKE_LFLAGS_PREBIND") &&
- !project->variables()["TQMAKE_LIB_FLAG"].isEmpty() &&
- project->isActiveConfig("dll"))
- project->variables()["TQMAKE_LFLAGS"] += project->variables()["TQMAKE_LFLAGS_PREBIND"];
- if(!project->isEmpty("TQMAKE_INCDIR"))
- project->variables()["INCLUDEPATH"] += project->variables()["TQMAKE_INCDIR"];
- if(!project->isEmpty("TQMAKE_LIBDIR")) {
- if ( !project->isEmpty("TQMAKE_RPATH") )
- project->variables()["TQMAKE_LFLAGS"] += varGlue("TQMAKE_LIBDIR", " " + var("TQMAKE_RPATH"),
- " " + var("TQMAKE_RPATH"), "");
- project->variables()["TQMAKE_LIBDIR_FLAGS"] += varGlue( "TQMAKE_LIBDIR", "-L", " -L", "" );
- }
- if ( project->isActiveConfig("qtopia") ) {
- if(configs.findIndex("qtopialib") == -1)
- configs.append("qtopialib");
- if(configs.findIndex("qtopiainc") == -1)
- configs.append("qtopiainc");
- }
- if ( project->isActiveConfig("qtopiainc") )
- project->variables()["INCLUDEPATH"] += project->variables()["TQMAKE_INCDIR_TQTOPIA"];
- if ( project->isActiveConfig("qtopialib") ) {
- if(!project->isEmpty("TQMAKE_LIBDIR_TQTOPIA"))
- project->variables()["TQMAKE_LIBDIR_FLAGS"] += varGlue("TQMAKE_LIBDIR_TQTOPIA", "-L", " -L", "");
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_TQTOPIA"];
- }
- if ( project->isActiveConfig("qt") ) {
- if ( project->isActiveConfig("accessibility" ) )
- project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("TQT_ACCESSIBILITY_SUPPORT");
- if ( project->isActiveConfig("tablet") )
- project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("TQT_TABLET_SUPPORT");
- if(configs.findIndex("tqmoc")) configs.append("tqmoc");
- project->variables()["INCLUDEPATH"] += project->variables()["TQMAKE_INCDIR_QT"];
- if ( !project->isActiveConfig("debug") )
- project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("TQT_NO_DEBUG");
- if ( !is_qt ) {
- if ( !project->isEmpty("TQMAKE_RPATH") ) {
- if ( !project->isEmpty("TQMAKE_RTLDIR_QT") )
- project->variables()["TQMAKE_LFLAGS"] += varGlue("TQMAKE_RTLDIR_QT", " " + var("TQMAKE_RPATH"),
- " " + var("TQMAKE_RPATH"), "");
- else if ( !project->isEmpty("TQMAKE_LIBDIR_QT") )
- project->variables()["TQMAKE_LFLAGS"] += varGlue("TQMAKE_LIBDIR_QT", " " + var("TQMAKE_RPATH"),
- " " + var("TQMAKE_RPATH"), "");
- }
- if ( !project->isEmpty("TQMAKE_LIBDIR_QT") )
- project->variables()["TQMAKE_LIBDIR_FLAGS"] += varGlue("TQMAKE_LIBDIR_QT", "-L", " -L", "");
- if ( project->isActiveConfig("thread") && !project->isEmpty("TQMAKE_LIBS_TQT_THREAD") )
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_TQT_THREAD"];
- else
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_QT"];
- }
- }
- if ( project->isActiveConfig("opengl") && !project->isActiveConfig("dlopen_opengl")) {
- project->variables()["INCLUDEPATH"] += project->variables()["TQMAKE_INCDIR_OPENGL"];
- if(!project->isEmpty("TQMAKE_LIBDIR_OPENGL"))
- project->variables()["TQMAKE_LIBDIR_FLAGS"] += varGlue("TQMAKE_LIBDIR_OPENGL", "-L", " -L", "");
- if ( is_qt )
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_OPENGL_QT"];
- else
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_OPENGL"];
- }
- if ( extern_libs && (project->isActiveConfig("qt") || project->isActiveConfig("opengl")) ) {
- if(configs.findIndex("x11lib") == -1)
- configs.append("x11lib");
- if ( project->isActiveConfig("opengl") && configs.findIndex("x11inc") == -1 )
- configs.append("x11inc");
- }
- if ( project->isActiveConfig("x11") ) {
- if(configs.findIndex("x11lib") == -1)
- configs.append("x11lib");
- if(configs.findIndex("x11inc") == -1)
- configs.append("x11inc");
- }
- if ( project->isActiveConfig("x11inc") )
- project->variables()["INCLUDEPATH"] += project->variables()["TQMAKE_INCDIR_X11"];
- if ( project->isActiveConfig("x11lib") ) {
- if(!project->isEmpty("TQMAKE_LIBDIR_X11"))
- project->variables()["TQMAKE_LIBDIR_FLAGS"] += varGlue("TQMAKE_LIBDIR_X11", "-L", " -L", "");
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_X11"];
- }
- if ( project->isActiveConfig("x11sm") )
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_X11SM"];
- if ( project->isActiveConfig("dylib") )
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_DYNLOAD"];
- if ( project->isActiveConfig("thread") ) {
- if(project->isActiveConfig("qt"))
- project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("TQT_THREAD_SUPPORT");
- if ( !project->isEmpty("TQMAKE_CFLAGS_THREAD")) {
- project->variables()["TQMAKE_CFLAGS"] += project->variables()["TQMAKE_CFLAGS_THREAD"];
- project->variables()["PRL_EXPORT_CFLAGS"] += project->variables()["TQMAKE_CFLAGS_THREAD"];
- }
- if( !project->isEmpty("TQMAKE_CXXFLAGS_THREAD")) {
- project->variables()["TQMAKE_CXXFLAGS"] += project->variables()["TQMAKE_CXXFLAGS_THREAD"];
- project->variables()["PRL_EXPORT_CXXFLAGS"] += project->variables()["TQMAKE_CXXFLAGS_THREAD"];
- }
- project->variables()["INCLUDEPATH"] += project->variables()["TQMAKE_INCDIR_THREAD"];
- project->variables()["TQMAKE_LIBS"] += project->variables()["TQMAKE_LIBS_THREAD"];
- if(!project->isEmpty("TQMAKE_LFLAGS_THREAD"))
- project->variables()["TQMAKE_LFLAGS"] += project->variables()["TQMAKE_LFLAGS_THREAD"];
- }
- if ( project->isActiveConfig("tqmoc") )
- setMocAware(TRUE);
- TQString compile_flag = var("TQMAKE_COMPILE_FLAG");
- if(compile_flag.isEmpty())
- compile_flag = "-c";
- if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
- TQString prefix_flags = project->first("TQMAKE_CFLAGS_PREFIX_INCLUDE");
- if(prefix_flags.isEmpty())
- prefix_flags = "-include";
- compile_flag += " " + prefix_flags + " " + project->first("TQMAKE_ORIG_TARGET");
- }
- if(!project->isEmpty("ALLTQMOC_HEADER")) {
- initOutPaths(); // Need to fix outdirs since we do this before init() (because we could add to SOURCES et al)
- TQString alltqmoc = fileFixify(project->first("TQMOC_DIR") + "/alltqmoc.cpp", TQDir::currentDirPath(), Option::output_dir);
- project->variables()["SOURCES"].prepend(alltqmoc);
- project->variables()["HEADERS_ORIG"] = project->variables()["HEADERS"];
- project->variables()["HEADERS"].clear();
- }
- if ( project->isEmpty("TQMAKE_RUN_CC") )
- project->variables()["TQMAKE_RUN_CC"].append("$(CC) " + compile_flag + " $(CFLAGS) $(INCPATH) -o $obj $src");
- if ( project->isEmpty("TQMAKE_RUN_CC_IMP") )
- project->variables()["TQMAKE_RUN_CC_IMP"].append("$(CC) " + compile_flag + " $(CFLAGS) $(INCPATH) -o $@ $<");
- if ( project->isEmpty("TQMAKE_RUN_CXX") )
- project->variables()["TQMAKE_RUN_CXX"].append("$(CXX) " + compile_flag + " $(CXXFLAGS) $(INCPATH) -o $obj $src");
- if ( project->isEmpty("TQMAKE_RUN_CXX_IMP") )
- project->variables()["TQMAKE_RUN_CXX_IMP"].append("$(CXX) " + compile_flag + " $(CXXFLAGS) $(INCPATH) -o $@ $<");
- project->variables()["TQMAKE_FILETAGS"] += TQStringList::split("HEADERS SOURCES TARGET DESTDIR", " ");
- if( project->isActiveConfig("GNUmake") && !project->isEmpty("TQMAKE_CFLAGS_DEPS"))
- include_deps = TRUE; //do not generate deps
- if(project->isActiveConfig("compile_libtool"))
- Option::obj_ext = ".lo"; //override the .o
-
- MakefileGenerator::init();
- if ( project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
- if(!project->isEmpty("TQMAKE_APP_FLAG")) {
- if(project->isEmpty("DESTDIR"))
- project->values("DESTDIR").append("");
- project->variables()["DESTDIR"].first() += project->variables()["TARGET"].first() +
- ".app/Contents/MacOS/";
- project->variables()["TQMAKE_PKGINFO"].append(project->first("DESTDIR") + "../PkgInfo");
- project->variables()["ALL_DEPS"] += project->first("TQMAKE_PKGINFO");
-
- TQString plist = fileFixify(project->first("TQMAKE_INFO_PLIST"));
- if(plist.isEmpty())
- plist = specdir() + TQDir::separator() + "Info.plist." + project->first("TEMPLATE");
- if(TQFile::exists(Option::fixPathToLocalOS(plist))) {
- if(project->isEmpty("TQMAKE_INFO_PLIST"))
- project->variables()["TQMAKE_INFO_PLIST"].append(plist);
- project->variables()["TQMAKE_INFO_PLIST_OUT"].append(project->first("DESTDIR") +
- "../Info.plist");
- project->variables()["ALL_DEPS"] += project->first("TQMAKE_INFO_PLIST_OUT");
- if(!project->isEmpty("RC_FILE"))
- project->variables()["ALL_DEPS"] += project->first("DESTDIR") +
- "../Resources/application.icns";
- }
- }
- }
-
- if(!project->isEmpty("TQMAKE_INTERNAL_INCLUDED_FILES"))
- project->variables()["DISTFILES"] += project->variables()["TQMAKE_INTERNAL_INCLUDED_FILES"];
- project->variables()["DISTFILES"] += Option::mkfile::project_files;
-
- init2();
- project->variables()["TQMAKE_INTERNAL_PRL_LIBS"] << "TQMAKE_LIBDIR_FLAGS" << "TQMAKE_LIBS";
- if(!project->isEmpty("TQMAKE_MAX_FILES_PER_AR")) {
- bool ok;
- int max_files = project->first("TQMAKE_MAX_FILES_PER_AR").toInt(&ok);
- TQStringList ar_sublibs, objs = project->variables()["OBJECTS"] + project->variables()["OBJTQMOC"];
- if(ok && max_files > 5 && max_files < (int)objs.count()) {
- int obj_cnt = 0, lib_cnt = 0;
- TQString lib;
- for(TQStringList::Iterator objit = objs.begin(); objit != objs.end(); ++objit) {
- if((++obj_cnt) >= max_files) {
- if(lib_cnt) {
- lib.sprintf("lib%s-tmp%d.a", project->first("TQMAKE_ORIG_TARGET").latin1(), lib_cnt);
- ar_sublibs << lib;
- obj_cnt = 0;
- }
- lib_cnt++;
- }
- }
- }
- if(!ar_sublibs.isEmpty()) {
- project->variables()["TQMAKE_AR_SUBLIBS"] = ar_sublibs;
- project->variables()["TQMAKE_INTERNAL_PRL_LIBS"] << "TQMAKE_AR_SUBLIBS";
- }
- }
-
- if(project->isActiveConfig("compile_libtool")) {
- const TQString libtoolify[] = { "TQMAKE_RUN_CC", "TQMAKE_RUN_CC_IMP",
- "TQMAKE_RUN_CXX", "TQMAKE_RUN_CXX_IMP",
- "TQMAKE_LINK_THREAD", "TQMAKE_LINK", "TQMAKE_AR_CMD", "TQMAKE_LINK_SHLIB_CMD",
- TQString::null };
- for(int i = 0; !libtoolify[i].isNull(); i++) {
- TQStringList &l = project->variables()[libtoolify[i]];
- if(!l.isEmpty()) {
- TQString libtool_flags, comp_flags;
- if(libtoolify[i].startsWith("TQMAKE_LINK") || libtoolify[i] == "TQMAKE_AR_CMD") {
- libtool_flags += " --mode=link";
- if(project->isActiveConfig("staticlib")) {
- libtool_flags += " -static";
- } else {
- if(!project->isEmpty("TQMAKE_LIB_FLAG")) {
- int maj = project->first("VER_MAJ").toInt();
- int min = project->first("VER_MIN").toInt();
- int pat = project->first("VER_PAT").toInt();
- comp_flags += " -version-info " + TQString::number(10*maj + min) +
- ":" + TQString::number(pat) + ":0";
- if(libtoolify[i] != "TQMAKE_AR_CMD") {
- TQString rpath = Option::output_dir;
- if(!project->isEmpty("DESTDIR")) {
- rpath = project->first("DESTDIR");
- if(TQDir::isRelativePath(rpath))
- rpath.prepend(Option::output_dir + Option::dir_sep);
- }
- comp_flags += " -rpath " + Option::fixPathToTargetOS(rpath, FALSE);
- }
- }
- }
- if(project->isActiveConfig("plugin"))
- libtool_flags += " -module";
- } else {
- libtool_flags += " --mode=compile";
- }
- l.first().prepend("$(LIBTOOL)" + libtool_flags + " ");
- if(!comp_flags.isEmpty())
- l.first() += comp_flags;
- }
- }
- }
-}
-
-TQStringList
-UnixMakefileGenerator::combineSetLFlags(const TQStringList &list1, const TQStringList &list2)
-{
- if(project->isActiveConfig("no_smart_library_merge"))
- return list1 + list2;
-
- TQStringList ret;
- for(int i = 0; i < 2; i++) {
- const TQStringList *lst = i ? &list2 : &list1;
- for(TQStringList::ConstIterator it = lst->begin(); it != lst->end(); ++it) {
- if((*it).startsWith("-")) {
- if((*it).startsWith("-L")) {
- if(ret.findIndex((*it)) == -1)
- ret.append((*it));
- } else if((*it).startsWith("-l")) {
- while(1) {
- TQStringList::Iterator idx = ret.find((*it));
- if(idx == ret.end())
- break;
- ret.remove(idx);
- }
- ret.append((*it));
- } else if(project->isActiveConfig("macx") && (*it).startsWith("-framework")) {
- int as_one = TRUE;
- TQString framework_in;
- if((*it).length() > 11) {
- framework_in = (*it).mid(11);
- } else {
- if(it != lst->end()) {
- ++it;
- as_one = FALSE;
- framework_in = (*it);
- }
- }
- if(!framework_in.isEmpty()) {
- for(TQStringList::Iterator outit = ret.begin(); outit != ret.end(); ++outit) {
- if((*outit).startsWith("-framework")) {
- int found = 0;
- if((*outit).length() > 11) {
- if(framework_in == (*outit).mid(11))
- found = 1;
- } else {
- if(it != lst->end()) {
- ++outit;
- if(framework_in == (*outit)) {
- --outit;
- found = 2;
- }
- }
- }
- for(int i = 0; i < found; i++)
- outit = ret.remove(outit);
- }
- }
- if(as_one) {
- ret.append("-framework " + framework_in);
- } else {
- ret.append("-framework");
- ret.append(framework_in);
- }
- }
- } else {
-#if 1
- while(1) {
- TQStringList::Iterator idx = ret.find((*it));
- if(idx == ret.end())
- break;
- ret.remove(idx);
- }
-#endif
- ret.append((*it));
- }
- } else /*if(TQFile::exists((*it)))*/ {
- while(1) {
- TQStringList::Iterator idx = ret.find((*it));
- if(idx == ret.end())
- break;
- ret.remove(idx);
- }
- ret.append((*it));
- }
- }
- }
- return ret;
-}
-
-void
-UnixMakefileGenerator::processPrlVariable(const TQString &var, const TQStringList &l)
-{
- if(var == "TQMAKE_PRL_LIBS")
- project->variables()["TQMAKE_CURRENT_PRL_LIBS"] = combineSetLFlags(project->variables()["TQMAKE_CURRENT_PRL_LIBS"] +
- project->variables()["TQMAKE_LIBS"], l);
- else
- MakefileGenerator::processPrlVariable(var, l);
-}
-
-TQString
-UnixMakefileGenerator::findDependency(const TQString &dep)
-{
- TQStringList::Iterator it;
- {
- TQStringList &qut = project->variables()["TQMAKE_EXTRA_UNIX_TARGETS"];
- for(it = qut.begin(); it != qut.end(); ++it) {
- TQString targ = var((*it) + ".target");
- if(targ.isEmpty())
- targ = (*it);
- if(targ.endsWith(dep))
- return targ;
- }
- }
- {
- TQStringList &quc = project->variables()["TQMAKE_EXTRA_UNIX_COMPILERS"];
- for(it = quc.begin(); it != quc.end(); ++it) {
- TQString tmp_out = project->variables()[(*it) + ".output"].first();
- TQString tmp_cmd = project->variables()[(*it) + ".commands"].join(" ");
- if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
- continue;
- TQStringList &tmp = project->variables()[(*it) + ".input"];
- for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) {
- TQStringList &inputs = project->variables()[(*it2)];
- for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) {
- TQString out = tmp_out;
- TQFileInfo fi(Option::fixPathToLocalOS((*input)));
- out.replace("${TQMAKE_FILE_BASE}", fi.baseName());
- out.replace("${TQMAKE_FILE_NAME}", fi.filePath());
- if(out.endsWith(dep))
- return out;
- }
- }
- }
- }
- return MakefileGenerator::findDependency(dep);
-}
-
-TQStringList
-&UnixMakefileGenerator::findDependencies(const TQString &file)
-{
- TQStringList &ret = MakefileGenerator::findDependencies(file);
- // Note: The TQMAKE_IMAGE_COLLECTION file have all images
- // as dependency, so don't add precompiled header then
- if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")
- && file != project->first("TQMAKE_IMAGE_COLLECTION")) {
- TQString header_prefix = project->first("TQMAKE_ORIG_TARGET") + ".gch" + Option::dir_sep;
- header_prefix += project->first("TQMAKE_PRECOMP_PREFIX");
- if(file.endsWith(".c")) {
- TQString precomp_h = header_prefix + "c";
- if(!ret.contains(precomp_h))
- ret += precomp_h;
- } else {
- for(TQStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) {
- if(file.endsWith(*it)) {
- TQString precomp_h = header_prefix + "c++";
- if(!ret.contains(precomp_h))
- ret += precomp_h;
- break;
- }
- }
- }
- }
- return ret;
-}
-
-bool
-UnixMakefileGenerator::findLibraries()
-{
- TQPtrList<MakefileDependDir> libdirs;
- libdirs.setAutoDelete(TRUE);
- const TQString lflags[] = { "TQMAKE_LIBDIR_FLAGS", "TQMAKE_LIBS", TQString::null };
- for(int i = 0; !lflags[i].isNull(); i++) {
- TQStringList &l = project->variables()[lflags[i]];
- for(TQStringList::Iterator it = l.begin(); it != l.end(); ++it) {
- TQString stub, dir, extn, opt = (*it).stripWhiteSpace();
- if(opt.startsWith("-")) {
- if(opt.startsWith("-L")) {
- TQString r = opt.right(opt.length() - 2), l = r;
- fixEnvVariables(l);
- libdirs.append(new MakefileDependDir(r.replace("\"",""),
- l.replace("\"","")));
- } else if(opt.startsWith("-l")) {
- stub = opt.mid(2);
- } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
- if(opt.length() > 11) {
- opt = opt.mid(11);
- } else {
- ++it;
- opt = (*it);
- }
- extn = "";
- dir = "/System/Library/Frameworks/" + opt + ".framework/";
- stub = opt;
- }
- } else {
- extn = dir = "";
- stub = opt;
- int slsh = opt.findRev(Option::dir_sep);
- if(slsh != -1) {
- dir = opt.left(slsh);
- stub = opt.mid(slsh+1);
- }
- TQRegExp stub_reg("^.*lib(" + stub + "[^./=]*)\\.(.*)$");
- if(stub_reg.exactMatch(stub)) {
- stub = stub_reg.cap(1);
- extn = stub_reg.cap(2);
- }
- }
- if(!stub.isEmpty()) {
- const TQString modifs[] = { "", "-mt", TQString::null };
- for(int modif = 0; !modifs[modif].isNull(); modif++) {
- bool found = FALSE;
- TQStringList extens;
- if(!extn.isNull())
- extens << extn;
- else
- extens << project->variables()["TQMAKE_EXTENSION_SHLIB"].first() << "a";
- for(TQStringList::Iterator extit = extens.begin(); extit != extens.end(); ++extit) {
- if(dir.isNull()) {
- TQString lib_stub;
- for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
- if(TQFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub +
- modifs[modif] + "." + (*extit))) {
- lib_stub = stub + modifs[modif];
- break;
- }
- }
- if(!lib_stub.isNull()) {
- (*it) = "-l" + lib_stub;
- found = TRUE;
- break;
- }
- } else {
- if(TQFile::exists("lib" + stub + modifs[modif] + "." + (*extit))) {
- (*it) = "lib" + stub + modifs[modif] + "." + (*extit);
- found = TRUE;
- break;
- }
- }
- }
- if(!found && project->isActiveConfig("compile_libtool")) {
- for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
- if(TQFile::exists(mdd->local_dir + Option::dir_sep + "lib" + stub + modifs[modif] + Option::libtool_ext)) {
- (*it) = mdd->real_dir + Option::dir_sep + "lib" + stub + modifs[modif] + Option::libtool_ext;
- found = TRUE;
- break;
- }
- }
- }
- if(found)
- break;
-
- }
- }
- }
- }
- return FALSE;
-}
-
-TQString linkLib(const TQString &file, const TQString &libName) {
- TQString ret;
- TQRegExp reg("^.*lib(" + libName + "[^./=]*).*$");
- if(reg.exactMatch(file))
- ret = "-l" + reg.cap(1);
- return ret;
-}
-
-void
-UnixMakefileGenerator::processPrlFiles()
-{
- TQDict<void> processed;
- TQPtrList<MakefileDependDir> libdirs;
- libdirs.setAutoDelete(TRUE);
- const TQString lflags[] = { "TQMAKE_LIBDIR_FLAGS", "TQMAKE_LIBS", TQString::null };
- for(int i = 0; !lflags[i].isNull(); i++) {
- for(bool ret = FALSE; TRUE; ret = FALSE) {
- TQStringList l_out;
- TQStringList &l = project->variables()[lflags[i]];
- for(TQStringList::Iterator it = l.begin(); it != l.end(); ++it) {
- project->variables()["TQMAKE_CURRENT_PRL_LIBS"].clear();
- TQString opt = (*it).stripWhiteSpace();
- if(opt.startsWith("-")) {
- if(opt.startsWith("-L")) {
- TQString r = opt.right(opt.length() - 2), l = r;
- fixEnvVariables(l);
- libdirs.append(new MakefileDependDir(r.replace("\"",""),
- l.replace("\"","")));
- } else if(opt.startsWith("-l") && !processed[opt]) {
- TQString lib = opt.right(opt.length() - 2);
- for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
- if(!project->isActiveConfig("compile_libtool")) { //give them the .libs..
- TQString la = mdd->local_dir + Option::dir_sep + "lib" + lib + Option::libtool_ext;
- if(TQFile::exists(la) && TQFile::exists(mdd->local_dir + Option::dir_sep + ".libs")) {
- l_out.append("-L" + mdd->real_dir + Option::dir_sep + ".libs");
- libdirs.append(new MakefileDependDir(mdd->real_dir + Option::dir_sep + ".libs",
- mdd->local_dir + Option::dir_sep + ".libs"));
- }
- }
-
- TQString prl = mdd->local_dir + Option::dir_sep + "lib" + lib;
- if(processPrlFile(prl)) {
- if(prl.startsWith(mdd->local_dir))
- prl.replace(0, mdd->local_dir.length(), mdd->real_dir);
- opt = linkLib(prl, lib);
- processed.insert(opt, (void*)1);
- ret = TRUE;
- break;
- }
- }
- } else if(project->isActiveConfig("macx") && opt.startsWith("-framework")) {
- if(opt.length() > 11) {
- opt = opt.mid(11);
- } else {
- ++it;
- opt = (*it);
- }
- TQString prl = "/System/Library/Frameworks/" + opt +
- ".framework/" + opt;
- if(processPrlFile(prl))
- ret = TRUE;
- l_out.append("-framework");
- }
- if(!opt.isEmpty())
- l_out.append(opt);
- l_out = combineSetLFlags(l_out, project->variables()["TQMAKE_CURRENT_PRL_LIBS"]);
- } else {
- TQString lib = opt;
- if(!processed[lib] && processPrlFile(lib)) {
- processed.insert(lib, (void*)1);
- ret = TRUE;
- }
-#if 0
- if(ret)
- opt = linkLib(lib, "");
-#endif
- if(!opt.isEmpty())
- l_out.append(opt);
- l_out = combineSetLFlags(l_out, project->variables()["TQMAKE_CURRENT_PRL_LIBS"]);
- }
- }
- if(ret && l != l_out)
- l = l_out;
- else
- break;
- }
- }
-}
-
-TQString
-UnixMakefileGenerator::defaultInstall(const TQString &t)
-{
- if(t != "target" || project->first("TEMPLATE") == "subdirs")
- return TQString();
-
- bool resource = FALSE;
- const TQString root = "$(INSTALL_ROOT)";
- TQStringList &uninst = project->variables()[t + ".uninstall"];
- TQString ret, destdir=project->first("DESTDIR");
- TQString targetdir = Option::fixPathToTargetOS(project->first("target.path"), FALSE);
- if(!destdir.isEmpty() && destdir.right(1) != Option::dir_sep)
- destdir += Option::dir_sep;
- targetdir = fileFixify(targetdir);
- if(targetdir.right(1) != Option::dir_sep)
- targetdir += Option::dir_sep;
-
- TQStringList links;
- TQString target="$(TARGET)";
- if(project->first("TEMPLATE") == "app") {
- target = "$(TQMAKE_TARGET)";
- if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
- destdir += "../../../";
- target += ".app";
- resource = TRUE;
- }
- } else if(project->first("TEMPLATE") == "lib") {
- if(project->isActiveConfig("create_prl") && !project->isActiveConfig("no_install_prl") &&
- !project->isEmpty("TQMAKE_INTERNAL_PRL_FILE")) {
- TQString dst_prl = project->first("TQMAKE_INTERNAL_PRL_FILE");
- int slsh = dst_prl.findRev('/');
- if(slsh != -1)
- dst_prl = dst_prl.right(dst_prl.length() - slsh - 1);
- dst_prl = root + targetdir + dst_prl;
- ret += "-$(INSTALL_FILE) \"" + project->first("TQMAKE_INTERNAL_PRL_FILE") + "\" \"" + dst_prl + "\"";
- if(!uninst.isEmpty())
- uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_prl + "\"");
- }
- if(project->isActiveConfig("create_libtool") && !project->isActiveConfig("compile_libtool")) {
- TQString src_lt = var("TQMAKE_ORIG_TARGET");
- int slsh = src_lt.findRev(Option::dir_sep);
- if(slsh != -1)
- src_lt = src_lt.right(src_lt.length() - slsh);
- int dot = src_lt.find('.');
- if(dot != -1)
- src_lt = src_lt.left(dot);
- src_lt += Option::libtool_ext;
- src_lt.prepend("lib");
- TQString dst_lt = root + targetdir + src_lt;
- if(!project->isEmpty("DESTDIR")) {
- src_lt.prepend(var("DESTDIR"));
- src_lt = Option::fixPathToLocalOS(fileFixify(src_lt,
- TQDir::currentDirPath(), Option::output_dir));
- }
- if(!ret.isEmpty())
- ret += "\n\t";
- ret += "-$(INSTALL_FILE) \"" + src_lt + "\" \"" + dst_lt + "\"";
- if(!uninst.isEmpty())
- uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_lt + "\"");
- }
- if(project->isActiveConfig("create_pc")) {
- TQString src_pc = var("TQMAKE_ORIG_TARGET");
- int slsh = src_pc.findRev(Option::dir_sep);
- if(slsh != -1)
- src_pc = src_pc.right(src_pc.length() - slsh);
- int dot = src_pc.find('.');
- if(dot != -1)
- src_pc = src_pc.left(dot);
- src_pc += ".pc";
- TQString d = root + targetdir + "pkgconfig" + Option::dir_sep;
- TQString dst_pc = d + src_pc;
- if(!project->isEmpty("DESTDIR")) {
- src_pc.prepend(var("DESTDIR"));
- src_pc = Option::fixPathToLocalOS(fileFixify(src_pc,
- TQDir::currentDirPath(), Option::output_dir));
- }
- if(!ret.isEmpty())
- ret += "\n\t";
- ret += mkdir_p_asstring(d) + "\n\t";
- ret += "-$(INSTALL_FILE) \"" + src_pc + "\" \"" + dst_pc + "\"";
- if(!uninst.isEmpty())
- uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_pc + "\"");
- }
- if(1==1) { // install tmoc and tqt-replace-stream files
- TQString src_pc = "";
- TQString d = root + Option::dir_sep + "usr" + Option::dir_sep + "bin";
- TQString dst_pc = d;
- if(!project->isEmpty("DESTDIR")) {
- src_pc.prepend(var("DESTDIR"));
- src_pc = Option::fixPathToLocalOS(fileFixify(src_pc,
- TQDir::currentDirPath(), Option::output_dir));
- }
- if(!ret.isEmpty())
- ret += "\n\t";
- ret += mkdir_p_asstring(d) + "\n\t";
- ret += "-$(INSTALL_FILE) \"" + src_pc + "/tmoc" + "\" \"" + dst_pc + "/tmoc" + "\"" + "\n\t";
- ret += "chmod +x \"" + dst_pc + "/tmoc" + "\"" + "\n\t";
- ret += "-$(INSTALL_FILE) \"" + src_pc + "/tqt-replace-stream" + "\" \"" + dst_pc + "/tqt-replace-stream" + "\"" + "\n\t";
- ret += "chmod +x \"" + dst_pc + "/tqt-replace-stream" + "\"" + "\n\t";
- if(!uninst.isEmpty())
- uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_pc + "/tmoc" + "\"");
- uninst.append("-$(DEL_FILE) \"" + dst_pc + "/tqt-replace-stream" + "\"");
- }
- if ( project->isEmpty("TQMAKE_CYGWIN_SHLIB") ) {
- if ( !project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") ) {
- if ( project->isEmpty("TQMAKE_HPUX_SHLIB") ) {
- links << "$(TARGET0)" << "$(TARGET1)" << "$(TARGET2)";
- } else {
- links << "$(TARGET0)";
- }
- }
- }
- }
-
- if(!resource && project->isActiveConfig("compile_libtool")) {
- TQString src_targ = target;
- if(src_targ == "$(TARGET)")
- src_targ = "$(TARGETL)";
- TQString dst_dir = fileFixify(targetdir);
- if(TQDir::isRelativePath(dst_dir))
- dst_dir = Option::fixPathToTargetOS(Option::output_dir + Option::dir_sep + dst_dir);
- ret = "-$(LIBTOOL) --mode=install cp \"" + src_targ + "\" \"" + root + dst_dir + "\"";
- uninst.append("-$(LIBTOOL) --mode=uninstall \"" + src_targ + "\"");
- } else {
- TQString src_targ = target;
- if(!destdir.isEmpty())
- src_targ = Option::fixPathToTargetOS(destdir + target, FALSE);
- TQString dst_targ = root + targetdir + target;
- if(!ret.isEmpty())
- ret += "\n\t";
- if(resource)
- ret += "$(DEL_FILE) -r \"" + dst_targ + "\"" + "\n\t";
- if(!ret.isEmpty())
- ret += "\n\t";
- ret += TQString(resource ? "-$(INSTALL_DIR)" : "-$(INSTALL_FILE)") + " \"" +
- src_targ + "\" \"" + dst_targ + "\"";
- if(!project->isActiveConfig("debug") && !project->isEmpty("TQMAKE_STRIP") &&
- (project->first("TEMPLATE") != "lib" || !project->isActiveConfig("staticlib"))) {
- ret += "\n\t-" + var("TQMAKE_STRIP");
- if(project->first("TEMPLATE") == "lib" && !project->isEmpty("TQMAKE_STRIPFLAGS_LIB"))
- ret += " " + var("TQMAKE_STRIPFLAGS_LIB");
- else if(project->first("TEMPLATE") == "app" && !project->isEmpty("TQMAKE_STRIPFLAGS_APP"))
- ret += " " + var("TQMAKE_STRIPFLAGS_APP");
- if(resource)
- ret = " \"" + dst_targ + "/Contents/MacOS/$(TQMAKE_TARGET)\"";
- else
- ret += " \"" + dst_targ + "\"";
- }
- if(!uninst.isEmpty())
- uninst.append("\n\t");
- if(resource)
- uninst.append("-$(DEL_FILE) -r \"" + dst_targ + "\"");
- else
- uninst.append("-$(DEL_FILE) \"" + dst_targ + "\"");
- if(!links.isEmpty()) {
- for(TQStringList::Iterator it = links.begin(); it != links.end(); it++) {
- if(Option::target_mode == Option::TARG_WIN_MODE ||
- Option::target_mode == Option::TARG_MAC9_MODE) {
- } else if(Option::target_mode == Option::TARG_UNIX_MODE ||
- Option::target_mode == Option::TARG_MACX_MODE) {
- TQString link = Option::fixPathToTargetOS(destdir + (*it), FALSE);
- int lslash = link.findRev(Option::dir_sep);
- if(lslash != -1)
- link = link.right(link.length() - (lslash + 1));
- TQString dst_link = root + targetdir + link;
- ret += "\n\t-$(SYMLINK) \"$(TARGET)\" \"" + dst_link + "\"";
- if(!uninst.isEmpty())
- uninst.append("\n\t");
- uninst.append("-$(DEL_FILE) \"" + dst_link + "\"");
- }
- }
- }
- }
- return ret;
-}