configure.py
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    59         while part in HB_MAKE_PARTS:
    59         while part in HB_MAKE_PARTS:
    60             HB_MAKE_PARTS.remove(part)
    60             HB_MAKE_PARTS.remove(part)
    61         if not part in HB_NOMAKE_PARTS:
    61         if not part in HB_NOMAKE_PARTS:
    62             HB_NOMAKE_PARTS.append(part)
    62             HB_NOMAKE_PARTS.append(part)
    63 
    63 
    64 def run_process(command, cwd=None):
    64 def run_process(args, cwd=None):
    65     code = 0
    65     code = 0
    66     output = ""
    66     output = ""
       
    67     if os.name == "nt":
       
    68         args = ["cmd.exe", "/C"] + args
    67     try:
    69     try:
    68         if cwd != None:
    70         if cwd != None:
    69             oldcwd = os.getcwd()
    71             oldcwd = os.getcwd()
    70             os.chdir(cwd)
    72             os.chdir(cwd)
    71         if sys.version_info[0] == 2 and sys.version_info[1] < 4:
    73         if sys.version_info[0] == 2 and sys.version_info[1] < 4:
    72             process = popen2.Popen4(command)
    74             process = popen2.Popen4(args)
    73             code = process.wait()
    75             code = process.wait()
    74             output = process.fromchild.read()
    76             output = process.fromchild.read()
    75         else:
    77         else:
    76             process = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    78             process = subprocess.Popen(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    77             (stdout, stderr) = process.communicate()
    79             (stdout, stderr) = process.communicate()
    78             code = process.returncode
    80             code = process.returncode
    79             output = stdout + stderr
    81             output = stdout + stderr
    80         if cwd != None:
    82         if cwd != None:
    81             os.chdir(oldcwd)
    83             os.chdir(oldcwd)
   130             group.add_option("--prefix", dest="prefix", metavar="dir",
   132             group.add_option("--prefix", dest="prefix", metavar="dir",
   131                              help="Install everything relative to <dir>. The default value is '%s'. "
   133                              help="Install everything relative to <dir>. The default value is '%s'. "
   132                                   "NOTE: Use '--prefix .' to configure a local setup. A local "
   134                                   "NOTE: Use '--prefix .' to configure a local setup. A local "
   133                                   "setup will install nothing else than the qmake "
   135                                   "setup will install nothing else than the qmake "
   134                                   "feature file." % prefix)
   136                                   "feature file." % prefix)
       
   137             group.add_option("--bin-dir", dest="bindir", metavar="dir",
       
   138                              help="Install executables to <dir>. The default value is 'PREFIX/bin'.")
       
   139             group.add_option("--lib-dir", dest="libdir", metavar="dir",
       
   140                              help="Install libraries to <dir>. The default value is 'PREFIX/lib'.")
       
   141             group.add_option("--doc-dir", dest="docdir", metavar="dir",
       
   142                              help="Install documentation to <dir>. The default value is 'PREFIX/doc'.")
       
   143             group.add_option("--include-dir", dest="includedir", metavar="dir",
       
   144                              help="Install headers to <dir>. The default value is 'PREFIX/include'.")
       
   145             group.add_option("--plugin-dir", dest="plugindir", metavar="dir",
       
   146                              help="Install plugins to <dir>. The default value is 'PREFIX/plugins'.")
       
   147             group.add_option("--resource-dir", dest="resourcedir", metavar="dir",
       
   148                              help="Install resources to <dir>. The default value is 'PREFIX/resources'.")
       
   149             group.add_option("--feature-dir", dest="featuredir", metavar="dir",
       
   150                              help="Install qmake feature files to <dir>. The default value is 'QTDIR/mkspecs/features'.")
   135             self.add_option_group(group)
   151             self.add_option_group(group)
   136         self.set_defaults(prefix=None)
   152         self.set_defaults(prefix=None)
       
   153         self.set_defaults(bindir=None)
       
   154         self.set_defaults(libdir=None)
       
   155         self.set_defaults(docdir=None)
       
   156         self.set_defaults(includedir=None)
       
   157         self.set_defaults(plugindir=None)
       
   158         self.set_defaults(resourcedir=None)
       
   159         self.set_defaults(featuredir=None)
   137 
   160 
   138         group = optparse.OptionGroup(self, "Configure options")
   161         group = optparse.OptionGroup(self, "Configure options")
   139         group.add_option("--platform", dest="platform", metavar="platform",
   162         group.add_option("--platform", dest="platform", metavar="platform",
   140                          help="Specify the platform (symbian/win32/unix). "
   163                          help="Specify the platform (symbian/win32/unix). "
   141                               "The one detected by qmake is used by default "
   164                               "The one detected by qmake is used by default "
   176         self.set_defaults(config=None)
   199         self.set_defaults(config=None)
   177         self.set_defaults(silent=False)
   200         self.set_defaults(silent=False)
   178         self.set_defaults(fast=False)
   201         self.set_defaults(fast=False)
   179         self.set_defaults(defines=None)
   202         self.set_defaults(defines=None)
   180 
   203 
       
   204         group = optparse.OptionGroup(self, "Host options")
       
   205         group.add_option("--host-qmake-bin", dest="hostqmakebin", metavar="path",
       
   206                          help="Specify the host qmake tool.")
       
   207         group.add_option("--host-make-bin", dest="hostmakebin", metavar="path",
       
   208                          help="Specify the host make tool (make, nmake, mingw32-make, gmake...).")
       
   209         self.set_defaults(hostqmakebin=None)
       
   210         self.set_defaults(hostmakebin=None)
       
   211 
   181         group = optparse.OptionGroup(self, "qmake options")
   212         group = optparse.OptionGroup(self, "qmake options")
   182         group.add_option("--qmake-bin", dest="qmakebin", metavar="path",
   213         group.add_option("--qmake-bin", dest="qmakebin", metavar="path",
   183                          help="Specify the path to the qmake. The one "
   214                          help="Specify the path to the qmake. The one "
   184                               "in PATH is used by default if not specified.")
   215                               "in PATH is used by default if not specified.")
   185         group.add_option("--qmake-spec", dest="qmakespec", metavar="spec",
   216         group.add_option("--qmake-spec", dest="qmakespec", metavar="spec",
   276         self._platform = None
   307         self._platform = None
   277         self._make = None
   308         self._make = None
   278         self._error = None
   309         self._error = None
   279         self._qmake = qmake
   310         self._qmake = qmake
   280         self._spec = None
   311         self._spec = None
       
   312         self._version = None
       
   313         self._features = None
       
   314         self._qtdir = None
   281 
   315 
   282     def name(self):
   316     def name(self):
   283         if not self._platform:
   317         if not self._platform:
   284             self._platform = self._detect_platform()
   318             self._detect_qt()
   285         return self._platform
   319         return self._platform
   286 
   320 
   287     def make(self):
   321     def make(self):
   288         if not self._make:
   322         if not self._make:
   289             self._make = self._detect_make()
   323             self._make = self._detect_make()
   290         return self._make
   324         return self._make
   291 
   325 
   292     def qmake(self):
   326     def qmake(self):
       
   327         if not self._qmake:
       
   328             self._detect_qt()
   293         return self._qmake
   329         return self._qmake
   294 
   330 
   295     def error(self):
   331     def error(self):
   296         return self._error
   332         return self._error
   297 
   333 
   298     def spec(self):
   334     def spec(self):
       
   335         if not self._spec:
       
   336             self._detect_qt()
   299         return self._spec
   337         return self._spec
   300 
   338 
   301     def _detect_platform(self):
   339     def version(self):
       
   340         if not self._version:
       
   341             self._detect_qt()
       
   342         return self._version
       
   343 
       
   344     def features(self):
       
   345         if not self._features:
       
   346             self._detect_qt()
       
   347         return self._features
       
   348 
       
   349     def qtdir(self):
       
   350         if not self._qtdir:
       
   351             self._detect_qt()
       
   352         return self._qtdir
       
   353 
       
   354     def _detect_qt(self):
   302         lines = list()
   355         lines = list()
   303         lines.append("symbian:message(symbian)\n")
   356         lines.append("symbian:message(platform:symbian)\n")
   304         lines.append("else:macx:message(macx)\n")
   357         lines.append("else:macx:message(platform:macx)\n")
   305         lines.append("else:unix:message(unix)\n")
   358         lines.append("else:unix:message(platform:unix)\n")
   306         lines.append("else:win32:message(win32)\n")
   359         lines.append("else:win32:message(platform:win32)\n")
       
   360 
       
   361         lines.append("message(version:$$[QT_VERSION])\n")
       
   362         lines.append("message(libraries:$$[QT_INSTALL_LIBS])\n")
       
   363         lines.append("message(features:$$[QMAKE_MKSPECS]/features)\n")
   307 
   364 
   308         try:
   365         try:
   309             if not os.path.exists("tmp"):
   366             if not os.path.exists("tmp"):
   310                 os.makedirs("tmp")
   367                 os.makedirs("tmp")
   311             fd, filepath = tempfile.mkstemp(dir="tmp", text=True, suffix=".pro")
   368             fd, filepath = tempfile.mkstemp(dir="tmp", text=True, suffix=".pro")
   313             file.writelines(lines)
   370             file.writelines(lines)
   314             file.close()
   371             file.close()
   315         except Exception, e:
   372         except Exception, e:
   316             print(e)
   373             print(e)
   317             self._error = "Unable to write a temporary file. Make sure to configure in a writable directory."
   374             self._error = "Unable to write a temporary file. Make sure to configure in a writable directory."
   318             return None
   375             return
   319 
   376 
   320         # do not use .qmake.cache when detecting the platform
   377         # do not use .qmake.cache when detecting the platform
   321         args = []
   378         args = [self._qmake, "-nocache", os.path.split(filepath)[1]]
   322         if os.name == "nt":
       
   323             args += "cmd.exe", "/C"
       
   324         args += [self._qmake, "-nocache", os.path.split(filepath)[1]]
       
   325         if self._spec:
   379         if self._spec:
   326             args += ["-spec", self._spec]
   380             args += ["-spec", self._spec]
   327         (code, output) = run_process(args, "tmp")
   381         (code, output) = run_process(args, "tmp")
   328         shutil.rmtree("tmp", ignore_errors=True)
   382         shutil.rmtree("tmp", ignore_errors=True)
   329         if code != 0:
   383         if code != 0:
   330             self._error = "Unable to execute %s" % self._qmake
   384             self._error = "Unable to execute %s" % self._qmake
   331             if self._qmake == "qmake":
   385             if self._qmake == "qmake":
   332                 self._error += ". Add qmake to PATH or pass --qmake-bin <path/to/qmake>."
   386                 self._error += ". Add qmake to PATH or pass --qmake-bin <path/to/qmake>."
   333             return None
       
   334 
   387 
   335         try:
   388         try:
   336             return re.match("Project MESSAGE: (\w+)", output).group(1)
   389             self._platform = re.search("Project MESSAGE: platform:(\S+)", output).group(1)
       
   390             self._version = re.search("Project MESSAGE: version:(\S+)", output).group(1)
       
   391             self._qtdir = re.search("Project MESSAGE: libraries:(\S+)", output).group(1)
       
   392             self._features = re.search("Project MESSAGE: features:(\S+)", output).group(1)
   337         except:
   393         except:
   338             self._error = "Unable to parse qmake output (%s)" % output.strip()
   394             self._error = "Unable to parse qmake output (%s)" % output.strip()
   339             if output.find("QMAKESPEC") != -1:
   395             if output.find("QMAKESPEC") != -1:
   340                 self._error += ". Set QMAKESPEC environment variable or pass --qmake-spec <spec>."
   396                 self._error += ". Set QMAKESPEC environment variable or pass --qmake-spec <spec>."
   341         return None
   397         return None
   371 
   427 
   372     def setup(self, sourcedir, builddir):
   428     def setup(self, sourcedir, builddir):
   373         self._sourcedir = sourcedir
   429         self._sourcedir = sourcedir
   374         self._builddir = builddir
   430         self._builddir = builddir
   375 
   431 
   376     def compile(self, test, patterns=None):
   432     def compile(self, test):
   377         code = -1
   433         code = -1
   378         prevdir = os.getcwd()
   434         prevdir = os.getcwd()
   379         try:
   435         try:
       
   436             basename = os.path.basename(test)
   380             sourcedir = os.path.join(self._sourcedir, test)
   437             sourcedir = os.path.join(self._sourcedir, test)
   381             filepath = os.path.join(sourcedir, os.path.basename(sourcedir) + ".pro")
   438             filepath = os.path.join(sourcedir, basename + ".pro")
   382             builddir = os.path.join(self._builddir, test)
   439             builddir = os.path.join(self._builddir, test)
   383 
   440 
       
   441             # create build dir
   384             if not os.path.exists(builddir):
   442             if not os.path.exists(builddir):
   385                 os.makedirs(builddir)
   443                 os.makedirs(builddir)
   386             os.chdir(builddir)
   444             os.chdir(builddir)
   387 
   445 
       
   446             # run qmake & make
   388             args = [self._qmake, filepath]
   447             args = [self._qmake, filepath]
   389             if self._spec:
   448             if self._spec:
   390                 args += ["-spec", self._spec]
   449                 args += ["-spec", self._spec]
   391             run_process(args)
   450             run_process(args)
   392             (code, output) = run_process(self._make)
   451             (code, output) = run_process([self._make])
   393             if code == 0 and patterns:
   452 
       
   453             # make return value is not reliable
       
   454             if self._platform == "symbian":
       
   455                 # on symbian, check that no error patterns such as '***' can be found from build output
       
   456                 patterns = ["\\*\\*\\*", "Errors caused tool to abort"]
   394                 for pattern in patterns:
   457                 for pattern in patterns:
   395                     if re.search(pattern, output) != None:
   458                     if re.search(pattern, output) != None:
   396                         code = -1
   459                         code = -1
   397                         break
   460             else:
       
   461                 # on other platforms, check that the resulting executable exists
       
   462                 executable = os.path.join(builddir, "hbconftest_" + basename)
       
   463                 if os.name == "nt":
       
   464                     executable.append(".exe")
       
   465                 if not os.path.exists(executable) or not os.access(executable, os.X_OK):
       
   466                     code = -1
       
   467 
       
   468             # clean
   398             run_process([self._make, "clean"])
   469             run_process([self._make, "clean"])
       
   470 
   399         except:
   471         except:
   400             code = -1
   472             code = -1
   401         os.chdir(prevdir)
   473         os.chdir(prevdir)
   402         return code == 0
   474         return code == 0
   403 
   475 
   476 
   548 
   477     currentdir = os.path.abspath(os.getcwd())
   549     currentdir = os.path.abspath(os.getcwd())
   478     sourcedir = os.path.abspath(sys.path[0])
   550     sourcedir = os.path.abspath(sys.path[0])
   479 
   551 
   480     # default prefixes
   552     # default prefixes
   481     symbianprefix = None
   553     prefixes = { "symbian" : "$${EPOCROOT}epoc32",
   482     if platform.name() == "symbian":
       
   483         if os.path.isdir("/s60"):
       
   484             symbianprefix = "$${EPOCROOT}epoc32/include/hb"
       
   485         else:
       
   486             symbianprefix = "$${EPOCROOT}epoc32/include/mw/hb"
       
   487     prefixes = { "symbian" : symbianprefix,
       
   488                  "unix"    : "/usr/local/hb",
   554                  "unix"    : "/usr/local/hb",
       
   555                  "macx"    : "/usr/local/hb",
   489                  "win32"   : "C:/hb" }
   556                  "win32"   : "C:/hb" }
   490 
   557 
   491     # parse command line options
   558     # parse command line options
   492     parser = OptionParser(platform.name(), platform.make(), prefixes.get(platform.name(), currentdir))
   559     parser = OptionParser(platform.name(), platform.make(), prefixes.get(platform.name(), currentdir))
   493     (options, args) = parser.parse_args()
   560     (options, args) = parser.parse_args()
   497         options.developer = True
   564         options.developer = True
   498 
   565 
   499     print("Configuring Hb...")
   566     print("Configuring Hb...")
   500     print("INFO: Platform: %s" % platform.name())
   567     print("INFO: Platform: %s" % platform.name())
   501     print("INFO: Make: %s" % platform.make())
   568     print("INFO: Make: %s" % platform.make())
       
   569     print("INFO: Qt: %s in %s" % (platform.version(), platform.qtdir()))
   502 
   570 
   503     # warn about deprecated options
   571     # warn about deprecated options
   504     if options.qtanimation != None:
   572     if options.qtanimation != None:
   505         print("WARNING: --qt-animation and --qt-no-animation are DEPRECATED. Qt 4.6 includes the animation framework.")
   573         print("WARNING: --qt-animation and --qt-no-animation are DEPRECATED. Qt 4.6 includes the animation framework.")
   506     if options.qtgestures != None:
   574     if options.qtgestures != None:
   536     basedir = options.prefix
   604     basedir = options.prefix
   537     if platform.name() != "symbian":
   605     if platform.name() != "symbian":
   538         basedir = os.path.abspath(basedir)
   606         basedir = os.path.abspath(basedir)
   539 
   607 
   540     local = os.path.isdir(basedir) and (basedir == currentdir)
   608     local = os.path.isdir(basedir) and (basedir == currentdir)
   541     if not local:
       
   542         resourcedir = basedir + "/resources"
       
   543     else:
       
   544         resourcedir = sourcedir + "/src/hbcore/resources"
       
   545 
   609 
   546     # generate local build wrapper headers
   610     # generate local build wrapper headers
   547     synchb = "bin/synchb.py"
   611     synchb = "bin/synchb.py"
   548     if options.verbose:
   612     if options.verbose:
   549         synchb = "%s -v" % synchb
   613         synchb = "%s -v" % synchb
   550         print("INFO: Running %s" % synchb)
   614         print("INFO: Running %s" % synchb)
   551     os.system("python %s/%s -i %s -o %s" % (sourcedir, synchb, sourcedir, currentdir))
   615     os.system("python %s/%s -i %s -o %s" % (sourcedir, synchb, sourcedir, currentdir))
   552 
       
   553     # write config
       
   554     config = ConfigFile()
       
   555     config.set_value("HB_INSTALL_DIR", ConfigFile.format_dir(basedir))
       
   556     config.set_value("HB_RESOURCES_DIR", ConfigFile.format_dir(resourcedir))
       
   557 
   616 
   558     # generate a qrc for resources
   617     # generate a qrc for resources
   559     args = [os.path.join(sourcedir, "bin/resourcifier.py")]
   618     args = [os.path.join(sourcedir, "bin/resourcifier.py")]
   560     args += ["-i", "%s" % os.path.join(sys.path[0], "src/hbcore/resources")]
   619     args += ["-i", "%s" % os.path.join(sys.path[0], "src/hbcore/resources")]
   561     # TODO: make it currentdir
   620     # TODO: make it currentdir
   569     if options.verbose:
   628     if options.verbose:
   570         print("INFO: Running %s" % " ".join(args))
   629         print("INFO: Running %s" % " ".join(args))
   571     os.system("python %s" % " ".join(args))
   630     os.system("python %s" % " ".join(args))
   572 
   631 
   573     # compilation tests to detect available features
   632     # compilation tests to detect available features
       
   633     config = ConfigFile()
   574     test = ConfigTest(platform)
   634     test = ConfigTest(platform)
   575     test.setup(sourcedir, currentdir)
   635     test.setup(sourcedir, currentdir)
   576     print("INFO: Detecting available features...")
   636     print("\nDetecting available features...")
   577     patterns = { "symbian" : ["\\*\\*\\*", "Errors caused tool to abort"],
       
   578                  "maemo"   : ["\\*\\*\\*"],
       
   579                  "unix"    : ["\\*\\*\\*"],
       
   580                  "win32"   : ["\\*\\*\\*"] }
       
   581     if options.qtmobility == None:
   637     if options.qtmobility == None:
   582         options.qtmobility = test.compile("config.tests/all/mobility", patterns.get(platform.name(), None))
   638         options.qtmobility = test.compile("config.tests/all/mobility")
   583         print("INFO:\tQt Mobility:\t\t\t%s" % options.qtmobility)
       
   584     if options.qtmobility:
   639     if options.qtmobility:
   585         config.add_value("DEFINES", "HB_HAVE_QT_MOBILITY")
   640         config.add_value("DEFINES", "HB_HAVE_QT_MOBILITY")
       
   641     print("INFO: Qt Mobility:\t\t\t%s" % options.qtmobility)
   586     if platform.name() == "symbian":
   642     if platform.name() == "symbian":
   587         sgimagelite_result = test.compile("config.tests/symbian/sgimagelite", patterns.get(platform.name(), None))
   643         sgimagelite_result = test.compile("config.tests/symbian/sgimagelite")
   588         if sgimagelite_result:
   644         if sgimagelite_result:
   589             config.add_value("CONFIG", "sgimagelite_support")
   645             config.add_value("CONFIG", "sgimage")
   590         print("INFO:\tSgImage-Lite:\t\t\t%s" % sgimagelite_result)
   646         print("INFO: SgImage-Lite:\t\t\t%s" % sgimagelite_result)
   591     if options.dui == None:
   647     if options.dui == None:
   592         options.dui = test.compile("config.tests/maemo/dui", patterns.get(platform.name(), None))
   648         options.dui = test.compile("config.tests/maemo/dui")
   593         print("INFO:\tDirect UI:\t\t\t%s" % options.dui)
       
   594     if options.dui:
   649     if options.dui:
   595         config.add_value("CONFIG", "hb_maemo_dui")
   650         config.add_value("CONFIG", "hb_maemo_dui")
   596         config.add_value("DEFINES", "HB_MAEMO_DUI")
   651         config.add_value("DEFINES", "HB_MAEMO_DUI")
   597 
   652     print("INFO: Direct UI:\t\t\t%s" % options.dui)
   598     config.set_value("HB_BIN_DIR", ConfigFile.format_dir(basedir + "/bin"))
   653 
   599     config.set_value("HB_LIB_DIR", ConfigFile.format_dir(basedir + "/lib"))
   654     # directories
   600     config.set_value("HB_DOC_DIR", ConfigFile.format_dir(basedir + "/doc"))
   655     if options.bindir == None:
   601     if not options.developer and platform.name() == "symbian":
   656         # TODO: symbian
   602         config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(basedir))
   657         options.bindir = basedir + "/bin"
   603     else:
   658     if options.libdir == None:
   604         config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(basedir + "/include"))
   659         # TODO: symbian
   605 
   660         options.libdir = basedir + "/lib"
   606     if platform.name() == "symbian":
   661     if options.docdir == None:
   607         plugins_dir = "$${EPOCROOT}resource/qt/plugins/hb"
   662         # TODO: symbian
   608     else:
   663         options.docdir = basedir + "/doc"
   609         plugins_dir = basedir + "/plugins"
   664     if options.includedir == None:
   610     config.set_value("HB_PLUGINS_DIR", ConfigFile.format_dir(plugins_dir))
   665         if platform.name() == "symbian" and not options.developer:
       
   666             if os.path.isdir("/s60"):
       
   667                 options.includedir = basedir + "/include/hb"
       
   668             else:
       
   669                 options.includedir = basedir + "/include/mw/hb"
       
   670         else:
       
   671             options.includedir = basedir + "/include"
       
   672     if options.plugindir == None:
       
   673         if platform.name() == "symbian":
       
   674             # TODO: fix to "$${EPOCROOT}resource/hb/plugins"
       
   675             options.plugindir = "$${EPOCROOT}resource/qt/plugins/hb"
       
   676         else:
       
   677             options.plugindir = basedir + "/plugins"
       
   678     if options.featuredir == None:
       
   679         options.featuredir = platform.features()
       
   680     if options.resourcedir == None:
       
   681         # TODO: fix this, some components want to write resources...
       
   682         #       thus, cannot point to the source tree!
       
   683         if not local:
       
   684             options.resourcedir = basedir + "/resources"
       
   685         else:
       
   686             options.resourcedir = sourcedir + "/src/hbcore/resources"
       
   687 
       
   688     config.set_value("HB_INSTALL_DIR", ConfigFile.format_dir(basedir))
       
   689     config.set_value("HB_BIN_DIR", ConfigFile.format_dir(options.bindir))
       
   690     config.set_value("HB_LIB_DIR", ConfigFile.format_dir(options.libdir))
       
   691     config.set_value("HB_DOC_DIR", ConfigFile.format_dir(options.docdir))
       
   692     config.set_value("HB_INCLUDE_DIR", ConfigFile.format_dir(options.includedir))
       
   693     config.set_value("HB_PLUGINS_DIR", ConfigFile.format_dir(options.plugindir))
       
   694     config.set_value("HB_RESOURCES_DIR", ConfigFile.format_dir(options.resourcedir))
       
   695     config.set_value("HB_FEATURES_DIR", ConfigFile.format_dir(options.featuredir))
       
   696 
       
   697 
       
   698     if os.name == "posix" or os.name == "mac":
       
   699         sharedmem = test.compile("config.tests/unix/sharedmemory")
       
   700         if sharedmem:
       
   701             (code, output) = run_process(["./hbconftest_sharedmemory"], "config.tests/unix/sharedmemory")
       
   702             sharedmem = (code == 0)
       
   703             if not sharedmem:
       
   704                 print("DEBUG:%s" % output)
       
   705         print("INFO: Shared Memory:\t\t\t%s" % sharedmem)
       
   706         if not sharedmem:
       
   707             print("WARNING:The amount of available shared memory is too low!")
       
   708             print "\tTry adjusting the shared memory configuration",
       
   709             if os.path.exists("/proc/sys/kernel/shmmax"):
       
   710                 print "(/proc/sys/kernel/shmmax)"
       
   711             elif os.path.exists("/etc/sysctl.conf"):
       
   712                 print "(/etc/sysctl.conf)"
       
   713 
       
   714 
       
   715 
       
   716     # TODO: get rid of this!
   611     if platform.name() == "symbian":
   717     if platform.name() == "symbian":
   612         config.set_value("HB_PLUGINS_EXPORT_DIR", ConfigFile.format_dir("$${EPOCROOT}epoc32/winscw/c/resource/qt/plugins/hb"))
   718         config.set_value("HB_PLUGINS_EXPORT_DIR", ConfigFile.format_dir("$${EPOCROOT}epoc32/winscw/c/resource/qt/plugins/hb"))
   613 
   719 
   614     if options.gestures:
   720     if options.gestures:
   615         config.add_value("DEFINES", "HB_GESTURE_FW")
   721         config.add_value("DEFINES", "HB_GESTURE_FW")
   630         print("ERROR: Unable to write hb_install_prf.")
   736         print("ERROR: Unable to write hb_install_prf.")
   631         return
   737         return
   632 
   738 
   633     config.set_value("HB_BUILD_DIR", ConfigFile.format_dir(currentdir))
   739     config.set_value("HB_BUILD_DIR", ConfigFile.format_dir(currentdir))
   634     config.set_value("HB_SOURCE_DIR", ConfigFile.format_dir(sourcedir))
   740     config.set_value("HB_SOURCE_DIR", ConfigFile.format_dir(sourcedir))
       
   741     config.set_value("HB_MKSPECS_DIR", ConfigFile.format_dir(basedir + "/mkspecs"))
   635 
   742 
   636     if platform.name() == "symbian":
   743     if platform.name() == "symbian":
   637         if os.path.isdir("/s60"):
   744         if os.path.isdir("/s60"):
   638             config.set_value("HB_EXPORT_DIR", "hb/%1/%2")
   745             config.set_value("HB_EXPORT_DIR", "hb/%1/%2")
   639             config.set_value("HB_PRIVATE_EXPORT_DIR", "hb/%1/private/%2")
   746             config.set_value("HB_PRIVATE_EXPORT_DIR", "hb/%1/private/%2")
   656     for part in HB_MAKE_PARTS:
   763     for part in HB_MAKE_PARTS:
   657         add_remove_part(part, True)
   764         add_remove_part(part, True)
   658 
   765 
   659     for nomake in HB_NOMAKE_PARTS:
   766     for nomake in HB_NOMAKE_PARTS:
   660         config.add_value("HB_NOMAKE_PARTS", nomake)
   767         config.add_value("HB_NOMAKE_PARTS", nomake)
       
   768 
       
   769     if options.qmakeopt:
       
   770         for qmakeopt in options.qmakeopt.split():
       
   771             config._lines.append(qmakeopt + "\n")
   661 
   772 
   662     if local:
   773     if local:
   663         config.add_value("CONFIG", "local")
   774         config.add_value("CONFIG", "local")
   664     if options.silent:
   775     if options.silent:
   665         config.add_value("CONFIG", "silent")
   776         config.add_value("CONFIG", "silent")
   698     config._lines.append("        DEFINES += QT_NO_WARNING_OUTPUT\n")
   809     config._lines.append("        DEFINES += QT_NO_WARNING_OUTPUT\n")
   699     config._lines.append("    }\n")
   810     config._lines.append("    }\n")
   700     config._lines.append("}\n")
   811     config._lines.append("}\n")
   701 
   812 
   702     # TODO: is there any better way to expose functions to the whole source tree?
   813     # TODO: is there any better way to expose functions to the whole source tree?
   703     config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/src/hbfunctions.prf"))
   814     config._lines.append("include(%s)\n" % (os.path.splitdrive(sourcedir)[1] + "/mkspecs/hb_functions.prf"))
   704 
   815 
   705     if options.verbose:
   816     if options.verbose:
   706         print("INFO: Writing .qmake.cache")
   817         print("INFO: Writing .qmake.cache")
   707     if not config.write(".qmake.cache"):
   818     if not config.write(".qmake.cache"):
   708         print("ERROR: Unable to write .qmake.cache.")
   819         print("ERROR: Unable to write .qmake.cache.")
   709         return
   820         return
       
   821 
       
   822     # build host tools
       
   823     if platform.name() == "symbian" or options.hostqmakebin != None or options.hostmakebin != None:
       
   824         print("\nBuilding host tools...")
       
   825         if options.hostqmakebin != None and options.hostmakebin != None:
       
   826             profile = "%s/src/hbtools/hbtools.pro" % sourcedir
       
   827             if os.path.exists(profile):
       
   828                 toolsdir = os.path.join(currentdir, "src/hbtools")
       
   829                 if not os.path.exists(toolsdir):
       
   830                     os.makedirs(toolsdir)
       
   831                 os.chdir(toolsdir)
       
   832                 os.system("\"%s\" -config silent %s" % (options.hostqmakebin, profile))
       
   833                 os.system("\"%s\"" % (options.hostmakebin))
       
   834                 os.chdir(currentdir)
       
   835         else:
       
   836             print("WARNING: Cannot build host tools, because no --host-qmake-bin and/or")
       
   837             print("         --host-make-bin was provided. Hb will attempt to run host")
       
   838             print("         tools from PATH.")
   710 
   839 
   711     # run qmake
   840     # run qmake
   712     if options.qmakebin:
   841     if options.qmakebin:
   713         qmake = options.qmakebin
   842         qmake = options.qmakebin
   714     profile = os.path.join(sourcedir, "hb.pro")
   843     profile = os.path.join(sourcedir, "hb.pro")
   720     if options.qmakespec:
   849     if options.qmakespec:
   721         qmake = "%s -spec %s" % (qmake, options.qmakespec)
   850         qmake = "%s -spec %s" % (qmake, options.qmakespec)
   722     if options.qmakeopt:
   851     if options.qmakeopt:
   723         qmake = "%s \\\"%s\\\"" % (qmake, options.qmakeopt)
   852         qmake = "%s \\\"%s\\\"" % (qmake, options.qmakeopt)
   724     if options.verbose:
   853     if options.verbose:
   725         print("INFO: Running %s" % qmake)
   854         print("\nRunning %s -cache %s %s" % (qmake, cachefile, profile))
       
   855     else:
       
   856         print("\nRunning qmake...")
   726     try:
   857     try:
   727         ret = os.system("%s -cache %s %s" % (qmake, cachefile, profile))
   858         ret = os.system("%s -cache %s %s" % (qmake, cachefile, profile))
   728     except KeyboardInterrupt:
   859     except KeyboardInterrupt:
   729         ret = -1
   860         ret = -1
   730     if ret != 0:
   861     if ret != 0:
   739         if os.path.exists(profile):
   870         if os.path.exists(profile):
   740             tsrcdir = os.path.join(currentdir, "tsrc")
   871             tsrcdir = os.path.join(currentdir, "tsrc")
   741             if not os.path.exists(tsrcdir):
   872             if not os.path.exists(tsrcdir):
   742                 os.makedirs(tsrcdir)
   873                 os.makedirs(tsrcdir)
   743             os.chdir(tsrcdir)
   874             os.chdir(tsrcdir)
       
   875             if options.verbose:
       
   876                 print("\nRunning %s %s" % (qmake, profile))
       
   877             else:
       
   878                 print("\nRunning qmake in tsrc...")
   744             os.system("%s %s" % (qmake, profile))
   879             os.system("%s %s" % (qmake, profile))
   745             os.chdir(currentdir)
   880             os.chdir(currentdir)
   746 
   881 
   747             # create output dirs
   882             # create output dirs
   748             outputdir = os.path.join(currentdir, "autotest")
   883             outputdir = os.path.join(currentdir, "autotest")