예제 #1
0
 def run_flex(target, source, env):
     start_dir = os.getcwd()
     os.chdir(var_dir)
     res = scons.Execute('flex  ' + src_file, chdir=var_dir)
     if res != 0:
         scons.Exit(1)
     os.chdir(start_dir)
예제 #2
0
    def __AutoConf(self):
        """This does the equivalent of GNU autoconf - it tries to make the build
        platform independent.

        Note that I've only done the minimum amount necessary to get things to
        compile on Ubuntu and CentOS (and specific versions of those to boot).
        If you want to compile on anything else you will likely need to update
        this."""
        context = scons.Configure(self.env)
        self.__lib_names = {}
        # Check for boost libraries with various names
        boost_libs = [
            'boost_thread', 'boost_regex', 'boost_unit_test_framework'
        ]
        for lib in boost_libs:
            # Prefer the multi-threaded versions (ending in -mt) if available
            if context.CheckLib(lib + '-mt', language='C++'):
                self.__lib_names[lib] = lib + '-mt'
            elif context.CheckLib(lib, language='C++'):
                self.__lib_names[lib] = lib
            else:
                print 'Error. Library %s not available' % lib
                scons.Exit(1)

        self.env = context.Finish()
예제 #3
0
def check_C_libraries(env, build):
    print 'Checking for C libraries'
    # Check for availability of C libraries
    conf = Script.Configure(env)
    print 'IMPLICIT', build.implicit_C_libs
    for c_lib in build.implicit_C_libs:
        if not conf.CheckLib(c_lib):
            Script.Exit(1)
    env = conf.Finish()

    print 'EXPLICIT'
    for c_lib in build.explicit_C_libs:
        print 'Checking for C library %s... ' % c_lib,
        if path.exists(c_lib):
            print 'yes'
        else:
            print 'no'
            Script.Exit(1)
예제 #4
0
def write_ecf_from_pecf(target, source, env):
    # Converts Pyxis format EC to XML
    pyxis_to_xml_cmd = [
        'el_toolkit', '-pyxis_to_xml', '-no_highlighting', '-in',
        str(source[0])
    ]
    sys.stdout.write(' '.join(pyxis_to_xml_cmd) + '\n')
    if subprocess.call(pyxis_to_xml_cmd) != 0:
        Script.Exit(1)
예제 #5
0
 def run_lemon(target, source, env):
     """The targets, source, and environment are passed by scons but we
     can ignore them as we don't need them."""
     # Copy the .y file into the variant dir
     shutil.copy(src_path, var_dir)
     ret = scons.Execute('lemon ' + var_path)
     if ret != 0:
         scons.Exit(1)
     # now rename the .c file to a .cc file
     shutil.move(generated_c_path, desired_cc_path)
예제 #6
0
    def __init__(self, target, machine, build, toolchain, available_features=[]):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == 'windows':
                raise Exception(
                    'must specify toolchain on Windows (msvs or gnu)')
            else:
                toolchain = 'gnu'

        if build is None:
            build = 'debug'

        if not build in ['debug', 'release']:
            raise Exception("invalid build type")

        if target not in ['windows', 'osx', 'linux', 'bsd']:
            raise Exception("invalid target platform")

        if machine.lower() not in ['x86_64', 'x86', 'i686', 'i586',
                                   'alpha', 'hppa', 'mips', 'mipsel', 's390',
                                   'sparc', 'ia64', 'armel', 'armhf', 'hurd-i386',
                                   'sh3', 'sh4',
                                   'kfreebsd-amd64', 'kfreebsd-i386',
                                   'i486', 'i386', 'ppc', 'ppc64', 'powerpc',
                                   'powerpc64', 'powerpcspe', 's390x',
                                   'amd64', 'em64t', 'intel64', 'arm64',
                                   'ppc64el']:
            raise Exception("invalid machine type")

        if toolchain not in ['gnu', 'msvs']:
            raise Exception('invalid toolchain type')

        if toolchain == 'msvs' and self.host_platform != 'windows':
            raise Exception(
                'cannot use msvs toolchain on non-windows platform')

        self.platform = target
        self.platform_is_posix = self.platform in ['linux', 'osx', 'bsd']
        self.platform_is_linux = self.platform == 'linux'
        self.platform_is_osx = self.platform == 'osx'
        self.platform_is_bsd = self.platform == 'bsd'
        self.platform_is_windows = self.platform == 'windows'

        self.machine = machine
        self.build = build
        self.build_is_debug = build == 'debug'
        self.build_is_release = build == 'release'

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == 'gnu'
        self.toolchain_is_msvs = self.toolchain == 'msvs'

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get('force32', 0))
        flags_force64 = int(Script.ARGUMENTS.get('force64', 0))
        if flags_force32 and flags_force64:
            logging.error('Both force32 and force64 cannot be enabled at once')
            Script.Exit(1)

        if flags_force32:
            if self.machine in ['powerpc', 'powerpc64', 'ppc', 'ppc64']:
                self.machine = 'powerpc'
            else:
                self.machine = 'x86'
        elif flags_force64:
            if self.machine in ['powerpc', 'powerpc64', 'ppc', 'ppc64']:
                self.machine = 'powerpc64'
            else:
                self.machine = 'x86_64'
        self.machine_is_64bit = self.machine.lower(
            ) in ['x86_64', 'powerpc64', 'ppc64', 'amd64', 'em64t', 'intel64']
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower(
            ) in ['x86', 'x86_64', 'i386', 'i486', 'i586', 'i686', 'em64t',
                  'intel64', 'amd64']
        self.architecture_is_powerpc = self.machine.lower(
            ) in ['powerpc', 'powerpc64', 'ppc', 'ppc64']
        self.architecture_is_arm = self.machine.lower().startswith('arm')

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get('staticlibs', 0))

        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info(
            "Crosscompile: %s" % ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            logging.info("Static dependencies: %s" % (
                "YES" if self.static_dependencies else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != 'linux':
            raise Exception(
                'Cross-compiling on a non-Linux host not currently supported')

        tools = ['default']
        toolpath = ['#build/']
        extra_arguments = {}
        import depends
        if int(Script.ARGUMENTS.get('qt5', 0)):
            tools.append('qt5')
            if self.machine_is_64bit:
                default_qtdir = depends.Qt.DEFAULT_QT5DIRS64.get(
                    self.platform, '')
            else:
                default_qtdir = depends.Qt.DEFAULT_QT5DIRS32.get(
                    self.platform, '')
        else:
            tools.append('qt4')
            default_qtdir = depends.Qt.DEFAULT_QT4DIRS.get(self.platform, '')
        tools.append('protoc')

        # Ugly hack to check the qtdir argument
        qtdir = Script.ARGUMENTS.get('qtdir',
                                     os.environ.get('QTDIR', default_qtdir))

        # Validate the specified qtdir exists
        if not os.path.exists(qtdir):
            logging.error("QT path does not exist or QT4 is not installed.")
            logging.error(
                "Please specify your QT path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3
        elif qtdir.find("qt3") != -1 or qtdir.find("qt/3") != -1:
            logging.error("Mixxx now requires QT4 instead of QT3 - please use your QT4 path with the qtdir build flag.")
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)

        # Previously this wasn't done for OSX, but I'm not sure why
        # -- rryan 6/8/2011
        extra_arguments['QTDIR'] = qtdir

        if self.platform_is_osx:
            tools.append('OSConsX')
            toolpath.append('#/build/osx/')
        if self.platform_is_windows and self.toolchain_is_msvs:
            # NOTE(rryan): Don't use the SCons mssdk tool since it does not
            # support x64.
            # In SConscript.env we use the MSVS tool to let you generate a
            # Visual Studio solution. Consider removing this.
            tools.extend(['msvs'])
            # SCons's built-in Qt tool attempts to link 'qt' into your binary if
            # you don't do this.
            extra_arguments['QT_LIB'] = ''
            # Causes SCons to bypass MSVC environment detection altogether
            # and depend on environment variables.
            # TODO(rryan): Expose SCons MSVC auto-detection options.
            extra_arguments['MSVC_USE_SCRIPT'] = None

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append('crossmingw')
            if self.platform_is_osx:
                tools.append('crossosx')

        self.env = Script.Environment(
            tools=tools, toolpath=toolpath, ENV=os.environ,
            **extra_arguments)
        self.read_environment_variables()

        # Now that environment variables have been read, we can detect the compiler.
        self.compiler_is_gcc = 'gcc' in self.env['CC']
        self.compiler_is_clang = 'clang' in self.env['CC']

        self.virtualize_build_dir()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS='-m32')
            elif flags_force64:
                self.env.Append(CCFLAGS='-m64')

        self.setup_platform_sdk()

        if self.platform_is_osx:
            if self.architecture_is_powerpc:
                self.env.Append(CCFLAGS='-arch ppc')
                self.env.Append(LINKFLAGS='-arch ppc')
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS='-arch i386')
                    self.env.Append(LINKFLAGS='-arch i386')
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS='-arch x86_64')
                    self.env.Append(LINKFLAGS='-arch x86_64')

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get('crosscompile_root', '')

            if crosscompile_root == '':
                print "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, 'include'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'lib'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'bin'))

        self.install_options()
예제 #7
0
    def __init__(self, target, machine, build, toolchain, available_features):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == 'windows':
                raise Exception(
                    'must specify toolchain on Windows (msvs or gnu)')
            else:
                toolchain = 'gnu'

        if build is None:
            build = 'debug'

        if not build in ['debug', 'release']:
            raise Exception("invalid build type")

        if target not in ['windows', 'osx', 'linux', 'bsd']:
            raise Exception("invalid target platform")

        if machine.lower() not in [
                'x86_64', 'x86', 'i686', 'i586', 'alpha', 'hppa', 's390',
                'sparc', 'ia64', 'armel', 'armhf', 'hurd-i386', 'armv5tel',
                'armv5tejl', 'armv6l', 'armv6hl', 'armv7l', 'armv7hl',
                'armv7hnl', 'sh3', 'sh4', 'kfreebsd-amd64', 'kfreebsd-i386',
                'i486', 'i386', 'ppc', 'ppc64', 'powerpc', 'powerpc64',
                'powerpcspe', 's390x', 'amd64', 'em64t', 'intel64', 'arm64',
                'ppc64el', 'ppc64le', 'm68k', 'mips', 'mipsel', 'mipsr6',
                'mipsr6el', 'mips64', 'mips64r6', 'mips64el', 'mips64r6el',
                'mipsn32', 'mipsn32el', 'mipsn32r6', 'mipsn32r6el',
                'mipsisa32r6', 'mipsisa32r6el', 'mipsisa64r6', 'mipsisa64r6el',
                'aarch64'
        ]:
            raise Exception("invalid machine type")

        if toolchain not in ['gnu', 'msvs']:
            raise Exception('invalid toolchain type')

        if toolchain == 'msvs' and self.host_platform != 'windows':
            raise Exception(
                'cannot use msvs toolchain on non-windows platform')

        self.platform = target
        self.platform_is_posix = self.platform in ['linux', 'osx', 'bsd']
        self.platform_is_linux = self.platform == 'linux'
        self.platform_is_osx = self.platform == 'osx'
        self.platform_is_bsd = self.platform == 'bsd'
        self.platform_is_windows = self.platform == 'windows'

        self.machine = machine
        self.build = build
        self.build_is_debug = build == 'debug'
        self.build_is_release = build == 'release'

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == 'gnu'
        self.toolchain_is_msvs = self.toolchain == 'msvs'

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get('force32', 0))
        flags_force64 = int(Script.ARGUMENTS.get('force64', 0))
        if flags_force32 and flags_force64:
            logging.error('Both force32 and force64 cannot be enabled at once')
            Script.Exit(1)

        if flags_force32:
            if self.machine in ['powerpc', 'powerpc64', 'ppc', 'ppc64']:
                self.machine = 'powerpc'
            else:
                self.machine = 'x86'
        elif flags_force64:
            if self.machine in ['powerpc', 'powerpc64', 'ppc', 'ppc64']:
                self.machine = 'powerpc64'
            else:
                self.machine = 'x86_64'
        self.machine_is_64bit = self.machine.lower() in [
            'x86_64', 'powerpc64', 'ppc64', 'amd64', 'em64t', 'intel64'
        ]
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower() in [
            'x86', 'x86_64', 'i386', 'i486', 'i586', 'i686', 'em64t',
            'intel64', 'amd64'
        ]
        self.architecture_is_powerpc = self.machine.lower() in [
            'powerpc', 'powerpc64', 'ppc', 'ppc64'
        ]
        self.architecture_is_arm = self.machine.lower().startswith('arm')

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get('staticlibs', 0))
        self.static_qt = int(Script.ARGUMENTS.get('staticqt', 0))

        self.bundle_pdbs = self.platform_is_windows and (
            self.build_is_debug
            or Script.ARGUMENTS.get('bundle_pdbs', '') in ('yes', 'y', '1'))

        self.scons_version = ('unknown'
                              if SCons.__version__.startswith('__VERSION') else
                              '%s (%s, %s)' % (
                                  SCons.__version__,
                                  SCons.__build__,
                                  SCons.__date__,
                              ))
        logging.info("SCons version: %s" % self.scons_version)
        logging.info("Python version: %s" % sys.version.replace('\n', ''))
        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info("Crosscompile: %s" %
                     ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            self.winlib_path = Script.ARGUMENTS.get('winlib', '')
            logging.info("Winlib Path: %s" % self.winlib_path)
            logging.info("Static dependencies: %s" %
                         ("YES" if self.static_dependencies else "NO"))
            logging.info("Static Qt: %s" % ("YES" if self.static_qt else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != 'linux':
            raise Exception(
                'Cross-compiling on a non-Linux host not currently supported')

        tools = ['default', 'qt5', 'protoc']
        toolpath = ['#build/']
        extra_arguments = {}
        from . import depends
        if self.machine_is_64bit:
            default_qtdir = depends.Qt.DEFAULT_QT5DIRS64.get(self.platform, '')
        else:
            default_qtdir = depends.Qt.DEFAULT_QT5DIRS32.get(self.platform, '')

        # Try fallback to pkg-config on Linux
        if not os.path.isdir(default_qtdir) and self.platform == 'linux':
            pkg_config_cmd = ['pkg-config', '--variable=includedir', 'Qt5Core']
            try:
                output = subprocess.check_output(pkg_config_cmd)
            except OSError:
                # pkg-config is not installed
                pass
            except subprocess.CalledProcessError:
                # pkg-config failed to find Qt5Core
                pass
            else:
                default_qtdir = output.decode('utf-8').rstrip()

        # Ugly hack to check the qtdir argument
        qtdir = Script.ARGUMENTS.get('qtdir',
                                     os.environ.get('QTDIR',
                                                    default_qtdir)).rstrip()

        # Validate the specified qtdir exists
        if not os.path.isdir(qtdir):
            logging.error(
                "Qt path (%s) does not exist or Qt is not installed." % qtdir)
            logging.error(
                "Please specify your Qt path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3 or qt4
        elif 'qt3' in qtdir or 'qt/3' in qtdir or 'qt4' in qtdir:
            logging.error(
                "Mixxx now requires Qt 5. Please set the qtdir build flag to the path to your Qt 5 installation."
            )
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)
        extra_arguments['QTDIR'] = qtdir

        if self.platform_is_osx:
            tools.append('OSConsX')
            toolpath.append('#/build/osx/')
        if self.platform_is_windows and self.toolchain_is_msvs:
            # NOTE(rryan): Don't use the SCons mssdk tool since it does not
            # support x64.
            # In SConscript.env we use the MSVS tool to let you generate a
            # Visual Studio solution. Consider removing this.
            tools.extend(['msvs', 'signtool'])
            toolpath.append('#/build/windows/')
            # SCons's built-in Qt tool attempts to link 'qt' into your binary if
            # you don't do this.
            extra_arguments['QT_LIB'] = ''
            # Causes SCons to bypass MSVC environment detection altogether
            # and depend on environment variables.
            # TODO(rryan): Expose SCons MSVC auto-detection options.
            extra_arguments['MSVC_USE_SCRIPT'] = None

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append('crossmingw')
            if self.platform_is_osx:
                tools.append('crossosx')

        self.env = Script.Environment(tools=tools,
                                      toolpath=toolpath,
                                      ENV=os.environ,
                                      **extra_arguments)
        self.read_environment_variables()

        # Now that environment variables have been read, we can detect the compiler.
        if self.toolchain_is_msvs:
            self.compiler_is_gcc = False
            self.compiler_is_clang = False
        else:
            cc_version_cmd = shlex.split(self.env['CC']) + ['--version']
            cc_version = subprocess.check_output(cc_version_cmd).decode(
                'utf-8')
            self.compiler_is_gcc = 'gcc' in cc_version.lower()
            self.compiler_is_clang = 'clang' in cc_version.lower()

            # Determine the major compiler version (only GCC)
            if self.compiler_is_gcc:
                self.gcc_major_version = None
                gcc_version_cmd = shlex.split(
                    self.env['CC']) + ['-dumpversion']
                gcc_version = subprocess.check_output(gcc_version_cmd).decode(
                    'utf-8')
                # If match is None we don't know the version.
                if not gcc_version is None:
                    version_split = gcc_version.split('.')
                    if version_split:
                        self.gcc_major_version = int(version_split[0])

        self.virtualize_build_dir()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS='-m32')
            elif flags_force64:
                self.env.Append(CCFLAGS='-m64')

        self.setup_platform_sdk()

        if self.platform_is_osx:
            if self.architecture_is_powerpc:
                self.env.Append(CCFLAGS='-arch ppc')
                self.env.Append(LINKFLAGS='-arch ppc')
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS='-arch i386')
                    self.env.Append(LINKFLAGS='-arch i386')
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS='-arch x86_64')
                    self.env.Append(LINKFLAGS='-arch x86_64')

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get('crosscompile_root', '')

            if crosscompile_root == '':
                print(
                    "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                )
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, 'include'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'lib'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'bin'))

        self.install_options()
예제 #8
0
파일: mixxx.py 프로젝트: leo-combes/mixxx
    def __init__(self,
                 target,
                 machine,
                 build,
                 toolchain,
                 available_features=[]):
        self.available_features = available_features
        self.host_platform = self.detect_platform()
        self.host_machine = self.detect_machine()
        self.flags = {}

        if target is None:
            target = self.host_platform

        if machine is None:
            machine = self.host_machine

        if toolchain is None:
            if self.host_platform == 'windows':
                raise Exception(
                    'must specify toolchain on Windows (msvs or gnu)')
            else:
                toolchain = 'gnu'

        if build is None:
            build = 'debug'

        if not build in ['debug', 'release']:
            raise Exception("invalid build type")

        if target not in ['windows', 'osx', 'linux', 'bsd']:
            raise Exception("invalid target platform")

        if machine not in [
                'x86_64', 'x86', 'i686', 'i586', 'alpha', 'hppa', 'mips',
                'mipsel', 's390', 'sparc', 'ia64', 'armel', 'armhf',
                'hurd-i386', 'sh3', 'sh4', 'kfreebsd-amd64', 'kfreebsd-i386',
                'i486', 'i386', 'powerpc', 'powerpc64', 'powerpcspe', 's390x',
                'amd64', 'AMD64', 'EM64T', 'INTEL64'
        ]:
            raise Exception("invalid machine type")

        if toolchain not in ['gnu', 'msvs']:
            raise Exception('invalid toolchain type')

        if toolchain == 'msvs' and self.host_platform != 'windows':
            raise Exception(
                'cannot use msvs toolchain on non-windows platform')

        self.platform = target
        self.platform_is_posix = self.platform in ['linux', 'osx', 'bsd']
        self.platform_is_linux = self.platform == 'linux'
        self.platform_is_osx = self.platform == 'osx'
        self.platform_is_bsd = self.platform == 'bsd'
        self.platform_is_windows = self.platform == 'windows'

        self.machine = machine
        self.build = build
        self.build_is_debug = build == 'debug'
        self.build_is_release = build == 'release'

        self.toolchain = toolchain
        self.toolchain_is_gnu = self.toolchain == 'gnu'
        self.toolchain_is_msvs = self.toolchain == 'msvs'

        self.crosscompile = self.host_platform != self.platform

        flags_force32 = int(Script.ARGUMENTS.get('force32', 0))
        flags_force64 = int(Script.ARGUMENTS.get('force64', 0))
        if flags_force32 and flags_force64:
            logging.error('Both force32 and force64 cannot be enabled at once')
            Script.Exit(1)

        if flags_force32:
            if self.machine in ['powerpc', 'powerpc64']:
                self.machine = 'powerpc'
            else:
                self.machine = 'x86'
        elif flags_force64:
            if self.machine in ['powerpc', 'powerpc64']:
                self.machine = 'powerpc64'
            else:
                self.machine = 'x86_64'
        self.machine_is_64bit = self.machine in [
            'x86_64', 'powerpc64', 'AMD64', 'EM64T', 'INTEL64'
        ]
        self.bitwidth = 64 if self.machine_is_64bit else 32
        self.architecture_is_x86 = self.machine.lower() in [
            'x86', 'x86_64', 'i386', 'i486', 'i586', 'i686', 'EM64T', 'INTEL64'
        ]
        self.architecture_is_powerpc = self.machine.lower() in [
            'powerpc', 'powerpc64'
        ]

        self.build_dir = util.get_build_dir(self.platform, self.bitwidth)

        # Currently this only works for Windows
        self.static_dependencies = int(Script.ARGUMENTS.get('staticlibs', 0))
        self.msvcdebug = int(Script.ARGUMENTS.get('msvcdebug', 0))

        logging.info("Target Platform: %s" % self.platform)
        logging.info("Target Machine: %s" % self.machine)
        logging.info("Build: %s" % self.build)
        logging.info("Toolchain: %s" % self.toolchain)
        logging.info("Crosscompile: %s" %
                     ("YES" if self.crosscompile else "NO"))
        if self.platform_is_windows:
            logging.info("Static dependencies: %s" %
                         ("YES" if self.static_dependencies else "NO"))
            logging.info("MSVC Debug build: %s" %
                         ("YES" if self.msvcdebug else "NO"))

        if self.crosscompile:
            logging.info("Host Platform: %s" % self.host_platform)
            logging.info("Host Machine: %s" % self.host_machine)

        if self.crosscompile and self.host_platform != 'linux':
            raise Exception(
                'Cross-compiling on a non-Linux host not currently supported')

        tools = ['default']
        toolpath = ['#build/']
        extra_arguments = {}
        tools.append('qt4')
        tools.append('protoc')

        # Ugly hack to check the qtdir argument
        import depends
        default_qtdir = depends.Qt.DEFAULT_QTDIRS.get(self.platform, '')
        qtdir = Script.ARGUMENTS.get('qtdir',
                                     os.environ.get('QTDIR', default_qtdir))

        # Validate the specified qtdir exists
        if not os.path.exists(qtdir):
            logging.error("QT path does not exist or QT4 is not installed.")
            logging.error(
                "Please specify your QT path by running 'scons qtdir=[path]'")
            Script.Exit(1)
        # And that it doesn't contain qt3
        elif qtdir.find("qt3") != -1 or qtdir.find("qt/3") != -1:
            logging.error(
                "Mixxx now requires QT4 instead of QT3 - please use your QT4 path with the qtdir build flag."
            )
            Script.Exit(1)
        logging.info("Qt path: %s" % qtdir)

        # Previously this wasn't done for OSX, but I'm not sure why
        # -- rryan 6/8/2011
        extra_arguments['QTDIR'] = qtdir

        if self.platform == 'osx':
            tools.append('OSConsX')
            toolpath.append('#/build/osx/')
        if self.platform_is_windows and self.toolchain == 'msvs':
            toolpath.append('msvs')
            extra_arguments['VCINSTALLDIR'] = os.getenv(
                'VCInstallDir')  # TODO(XXX) Why?
            extra_arguments['QT_LIB'] = ''  # TODO(XXX) Why?

        # Setup the appropriate toolchains for cross-compiling
        if self.crosscompile:
            if self.platform_is_windows:
                tools.append('crossmingw')
            if self.platform == 'osx':
                tools.append('crossosx')

        self.env = Script.Environment(tools=tools,
                                      toolpath=toolpath,
                                      ENV=os.environ,
                                      **extra_arguments)
        self.read_environment_variables()
        self.virtualize_build_dir()

        if self.toolchain_is_gnu:
            if flags_force32:
                self.env.Append(CCFLAGS='-m32')
            elif flags_force64:
                self.env.Append(CCFLAGS='-m64')

        if self.platform == 'osx':
            if self.machine == 'powerpc':
                self.env.Append(CCFLAGS='-arch ppc')
                self.env.Append(LINKFLAGS='-arch ppc')
            else:
                if self.bitwidth == 32:
                    self.env.Append(CCFLAGS='-arch i386')
                    self.env.Append(LINKFLAGS='-arch i386')
                elif self.bitwidth == 64:
                    self.env.Append(CCFLAGS='-arch x86_64')
                    self.env.Append(LINKFLAGS='-arch x86_64')

        if self.crosscompile:
            crosscompile_root = Script.ARGUMENTS.get('crosscompile_root', '')

            if crosscompile_root == '':
                print "Your build setup indicates this is a cross-compile, but you did not specify 'crosscompile_root', which is required."
                Script.Exit(1)

            crosscompile_root = os.path.abspath(crosscompile_root)
            self.env.Append(CPPPATH=os.path.join(crosscompile_root, 'include'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'lib'))
            self.env.Append(LIBPATH=os.path.join(crosscompile_root, 'bin'))

        self.install_options()