Example #1
0
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2, 4, 2)):
    # enable tool to build python extensions
    if conf.env.HAVE_PYTHON_H:
        conf.check_python_version(version)
        return

    interpreters = []

    if conf.env['EXTRA_PYTHON']:
        conf.all_envs['extrapython'] = conf.env.copy()
        conf.setenv('extrapython')
        conf.env['PYTHON'] = conf.env['EXTRA_PYTHON']
        conf.env['IS_EXTRA_PYTHON'] = 'yes'
        conf.find_program('python', var='PYTHON', mandatory=True)
        conf.check_tool('python')
        try:
            conf.check_python_version((3, 3, 0))
        except Exception:
            Logs.warn('extra-python needs to be Python 3.3 or later')
            raise
        interpreters.append(conf.env['PYTHON'])
        conf.setenv('default')

    conf.find_program('python', var='PYTHON', mandatory=mandatory)
    conf.check_tool('python')
    path_python = conf.find_program('python')
    conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python)
    conf.check_python_version(version)

    interpreters.append(conf.env['PYTHON'])
    conf.env.python_interpreters = interpreters
Example #2
0
def check_perl_version(conf, minver=None):
	"""
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""

	if getattr(Options.options, 'perlbinary', None):
		conf.env.PERL = Options.options.perlbinary
	else:
		conf.find_program('perl', var='PERL', mandatory=True)

	try:
		version = Utils.cmd_output([conf.env.PERL, '-e', 'printf "%vd",$^V'])
	except:
		conf.fatal('could not determine the perl version')

	conf.env.PERL_VERSION = version
	cver = ''
	if minver:
		try:
			ver = tuple(map(int, version.split('.')))
		except:
			conf.fatal('unsupported perl version %r' % version)
		if ver < minver:
			conf.fatal('perl is too old')

		cver = '.'.join(map(str,minver))
	conf.check_message('perl', cver, True, version)
Example #3
0
def check_perl_version(conf, minver=None):
	"""
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""

	if getattr(Options.options, 'perlbinary', None):
		conf.env.PERL = Options.options.perlbinary
	else:
		conf.find_program('perl', var='PERL', mandatory=True)

	try:
		version = Utils.cmd_output([conf.env.PERL, '-e', 'printf "%vd",$^V'])
	except:
		conf.fatal('could not determine the perl version')

	conf.env.PERL_VERSION = version
	cver = ''
	if minver:
		try:
			ver = tuple(map(int, version.split('.')))
		except:
			conf.fatal('unsupported perl version %r' % version)
		if ver < minver:
			conf.fatal('perl is too old')

		cver = '.'.join(map(str,minver))
	conf.check_message('perl', cver, True, version)
Example #4
0
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
    # enable tool to build python extensions
    conf.find_program('python', var='PYTHON', mandatory=mandatory)
    conf.check_tool('python')
    path_python = conf.find_program('python')
    conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python)
    conf.check_python_version(version)
Example #5
0
File: perl.py Project: runt18/samba
def check_perl_version(conf, minver=None):
    """
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""

    if getattr(Options.options, "perlbinary", None):
        conf.env.PERL = Options.options.perlbinary
    else:
        conf.find_program("perl", var="PERL", mandatory=True)

    try:
        version = Utils.cmd_output([conf.env.PERL, "-e", 'printf "%vd",$^V'])
    except:
        conf.fatal("could not determine the perl version")

    conf.env.PERL_VERSION = version
    cver = ""
    if minver:
        try:
            ver = tuple(map(int, version.split(".")))
        except:
            conf.fatal("unsupported perl version {0!r}".format(version))
        if ver < minver:
            conf.fatal("perl is too old")

        cver = ".".join(map(str, minver))
    conf.check_message("perl", cver, True, version)
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2, 4, 2)):
    # enable tool to build python extensions
    conf.find_program('python', var='PYTHON', mandatory=mandatory)
    conf.check_tool('python')
    path_python = conf.find_program('python')
    conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python)
    conf.check_python_version(version)
Example #7
0
def check_ruby_version(conf, minver=()):
	"""
	Checks if ruby is installed.
	If installed the variable RUBY will be set in environment.
	Ruby binary can be overridden by --with-ruby-binary config variable
	"""

	if Options.options.rubybinary:
		conf.env.RUBY = Options.options.rubybinary
	else:
		conf.find_program("ruby", var="RUBY", mandatory=True)

	ruby = conf.env.RUBY

	try:
		version = Utils.cmd_output([ruby, '-e', 'puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION = version

	try:
		ver = tuple(map(int, version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r' % version)

	cver = ''
	if minver:
		if ver < minver:
			conf.fatal('ruby is too old')
		cver = ".".join([str(x) for x in minver])

	conf.check_message('ruby', cver, True, version)
Example #8
0
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
    # enable tool to build python extensions
    if conf.env.HAVE_PYTHON_H:
        conf.check_python_version(version)
        return

    interpreters = []

    if conf.env['EXTRA_PYTHON']:
        conf.all_envs['extrapython'] = conf.env.copy()
        conf.setenv('extrapython')
        conf.env['PYTHON'] = conf.env['EXTRA_PYTHON']
        conf.env['IS_EXTRA_PYTHON'] = 'yes'
        conf.find_program('python', var='PYTHON', mandatory=True)
        conf.check_tool('python')
        try:
            conf.check_python_version((3, 3, 0))
        except Exception:
            Logs.warn('extra-python needs to be Python 3.3 or later')
            raise
        interpreters.append(conf.env['PYTHON'])
        conf.setenv('default')

    conf.find_program('python', var='PYTHON', mandatory=mandatory)
    conf.check_tool('python')
    path_python = conf.find_program('python')
    conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python)
    conf.check_python_version(version)

    interpreters.append(conf.env['PYTHON'])
    conf.env.python_interpreters = interpreters
Example #9
0
def check_ruby_version(conf, minver=()):
	"""
	Checks if ruby is installed.
	If installed the variable RUBY will be set in environment.
	Ruby binary can be overridden by --with-ruby-binary config variable
	"""

	if Options.options.rubybinary:
		conf.env.RUBY = Options.options.rubybinary
	else:
		conf.find_program("ruby", var="RUBY", mandatory=True)

	ruby = conf.env.RUBY

	try:
		version = Utils.cmd_output([ruby, '-e', 'puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION = version

	try:
		ver = tuple(map(int, version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r' % version)

	cver = ''
	if minver:
		if ver < minver:
			conf.fatal('ruby is too old')
		cver = ".".join([str(x) for x in minver])

	conf.check_message('ruby', cver, True, version)
Example #10
0
def find_msvc(conf):
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )
    v = conf.env
    compiler, version, path, includes, libdirs = detect_msvc(conf)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or (
        compiler == 'wsdk'
        and float(version) >= 6) or (compiler == 'intel'
                                     and float(version) >= 11)
    cxx = None
    if v.CXX: cxx = v.CXX
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name,
                                var='CXX',
                                path_list=path,
                                mandatory=True)
    cxx = conf.cmd_to_list(cxx)
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')
    link = v.LINK_CXX
    if not link:
        link = conf.find_program(linker_name, path_list=path, mandatory=True)
    ar = v.AR
    if not ar:
        ar = conf.find_program(lib_name, path_list=path, mandatory=True)
    mt = v.MT
    if has_msvc_manifest:
        mt = conf.find_program('MT', path_list=path, mandatory=True)
    v.MSVC_MANIFEST = has_msvc_manifest
    v.PATH = path
    v.CPPPATH = includes
    v.LIBPATH = libdirs
    v.CC = v.CXX = cxx
    v.CC_NAME = v.CXX_NAME = 'msvc'
    v.LINK = v.LINK_CXX = link
    if not v.LINK_CC:
        v.LINK_CC = v.LINK_CXX
    v.AR = ar
    v.MT = mt
    v.MTFLAGS = v.ARFLAGS = ['/NOLOGO']
    conf.check_tool('winres')
    if not conf.env.WINRC:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass
Example #11
0
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5, 0, 0)):
    #
    # TODO: use the @runonce mechanism for this.
    # The problem is that @runonce currently does
    # not seem to work together with @conf...
    # So @runonce (and/or) @conf needs fixing.
    #
    if "done" in done:
        return
    done["done"] = True
    conf.find_program('perl', var='PERL', mandatory=mandatory)
    conf.check_tool('perl')
    path_perl = conf.find_program('perl')
    conf.env.PERL_SPECIFIED = (conf.env.PERL != path_perl)
    conf.check_perl_version(version)

    def read_perl_config_var(cmd):
        return Utils.to_list(
            Utils.cmd_output([conf.env.PERL, '-MConfig', '-e', cmd]))

    def check_perl_config_var(var):
        conf.start_msg("Checking for perl $Config{%s}:" % var)
        try:
            v = read_perl_config_var('print $Config{%s}' % var)[0]
            conf.end_msg("'%s'" % (v), 'GREEN')
            return v
        except IndexError:
            conf.end_msg(False, 'YELLOW')
            pass
        return None

    vendor_prefix = check_perl_config_var('vendorprefix')

    perl_arch_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_arch_install_dir = check_perl_config_var('vendorarch')
    if perl_arch_install_dir is None:
        perl_arch_install_dir = "${LIBDIR}/perl5"
    conf.start_msg("PERL_ARCH_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_arch_install_dir), 'GREEN')
    conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir

    perl_lib_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_lib_install_dir = check_perl_config_var('vendorlib')
    if perl_lib_install_dir is None:
        perl_lib_install_dir = "${DATADIR}/perl5"
    conf.start_msg("PERL_LIB_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_lib_install_dir), 'GREEN')
    conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir

    perl_inc = read_perl_config_var('print "@INC"')
    perl_inc.remove('.')
    conf.start_msg("PERL_INC: ")
    conf.end_msg("%s" % (perl_inc), 'GREEN')
    conf.env.PERL_INC = perl_inc
Example #12
0
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5, 0, 0)):
    #
    # TODO: use the @runonce mechanism for this.
    # The problem is that @runonce currently does
    # not seem to work together with @conf...
    # So @runonce (and/or) @conf needs fixing.
    #
    if "done" in done:
        return
    done["done"] = True
    conf.find_program("perl", var="PERL", mandatory=mandatory)
    conf.check_tool("perl")
    path_perl = conf.find_program("perl")
    conf.env.PERL_SPECIFIED = conf.env.PERL != path_perl
    conf.check_perl_version(version)

    def read_perl_config_var(cmd):
        return Utils.to_list(Utils.cmd_output([conf.env.PERL, "-MConfig", "-e", cmd]))

    def check_perl_config_var(var):
        conf.start_msg("Checking for perl $Config{%s}:" % var)
        try:
            v = read_perl_config_var("print $Config{%s}" % var)[0]
            conf.end_msg("'%s'" % (v), "GREEN")
            return v
        except IndexError:
            conf.end_msg(False, "YELLOW")
            pass
        return None

    vendor_prefix = check_perl_config_var("vendorprefix")

    perl_arch_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_arch_install_dir = check_perl_config_var("vendorarch")
    if perl_arch_install_dir is None:
        perl_arch_install_dir = "${LIBDIR}/perl5"
    conf.start_msg("PERL_ARCH_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_arch_install_dir), "GREEN")
    conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir

    perl_lib_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_lib_install_dir = check_perl_config_var("vendorlib")
    if perl_lib_install_dir is None:
        perl_lib_install_dir = "${DATADIR}/perl5"
    conf.start_msg("PERL_LIB_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_lib_install_dir), "GREEN")
    conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir

    perl_inc = read_perl_config_var('print "@INC"')
    perl_inc.remove(".")
    conf.start_msg("PERL_INC: ")
    conf.end_msg("%s" % (perl_inc), "GREEN")
    conf.env.PERL_INC = perl_inc
Example #13
0
def find_msvc(conf):
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )
    v = conf.env
    compiler, path, includes, libdirs = detect_msvc(conf)
    v['PATH'] = path
    v['CPPPATH'] = includes
    v['LIBPATH'] = libdirs
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    cxx = None
    if v['CXX']: cxx = v['CXX']
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name, var='CXX', path_list=path)
    if not cxx: conf.fatal('%s was not found (compiler)' % compiler_name)
    cxx = conf.cmd_to_list(cxx)
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')
    v['CC'] = v['CXX'] = cxx
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass
    if not v['LINK_CXX']:
        link = conf.find_program(linker_name, path_list=path)
        if link: v['LINK_CXX'] = link
        else: conf.fatal('%s was not found (linker)' % linker_name)
    v['LINK'] = link
    if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX']
    if not v['AR']:
        stliblink = conf.find_program(lib_name, path_list=path)
        if not stliblink: return
        v['AR'] = stliblink
        v['ARFLAGS'] = ['/NOLOGO']
    manifesttool = conf.find_program('MT', path_list=path)
    if manifesttool:
        v['MT'] = manifesttool
        v['MTFLAGS'] = ['/NOLOGO']
    conf.check_tool('winres')
    if not conf.env['WINRC']:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
Example #14
0
def CHECK_XSLTPROC_MANPAGES(conf):
    '''check if xsltproc can run with the given stylesheets'''

    if not conf.CONFIG_SET('XSLTPROC'):
        conf.find_program('xsltproc', var='XSLTPROC')
    if not conf.CONFIG_SET('XSLTPROC'):
        return False

    s = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
    conf.CHECK_COMMAND('%s --nonet %s 2> /dev/null' % (conf.env.XSLTPROC, s),
                       msg='Checking for stylesheet %s' % s,
                       define='XSLTPROC_MANPAGES',
                       on_target=False,
                       boolean=True)
Example #15
0
def CHECK_XSLTPROC_MANPAGES(conf):
    '''check if xsltproc can run with the given stylesheets'''


    if not conf.CONFIG_SET('XSLTPROC'):
        conf.find_program('xsltproc', var='XSLTPROC')
    if not conf.CONFIG_SET('XSLTPROC'):
        return False

    s='http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
    conf.CHECK_COMMAND('%s --nonet %s 2> /dev/null' % (conf.env.XSLTPROC, s),
                             msg='Checking for stylesheet %s' % s,
                             define='XSLTPROC_MANPAGES', on_target=False,
                             boolean=True)
Example #16
0
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5,0,0)):
    if "done" in done:
        return
    done["done"] = True
    conf.find_program('perl', var='PERL', mandatory=mandatory)
    conf.check_tool('perl')
    path_perl = conf.find_program('perl')
    conf.env.PERL_SPECIFIED = (conf.env.PERL != path_perl)
    conf.check_perl_version(version)

    def read_perl_config_var(cmd):
        return Utils.to_list(Utils.cmd_output([conf.env.PERL, '-MConfig', '-e', cmd]))

    def check_perl_config_var(var):
        conf.start_msg("Checking for perl $Config{%s}:" % var)
        try:
            v = read_perl_config_var('print $Config{%s}' % var)[0]
            conf.end_msg("'%s'" % (v), 'GREEN')
            return v
        except IndexError:
            conf.end_msg(False, 'YELLOW')
            pass
        return None

    vendor_prefix = check_perl_config_var('vendorprefix')

    perl_arch_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_arch_install_dir = check_perl_config_var('vendorarch');
    if perl_arch_install_dir is None:
        perl_arch_install_dir = "${LIBDIR}/perl5";
    conf.start_msg("PERL_ARCH_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_arch_install_dir), 'GREEN')
    conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir

    perl_lib_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_lib_install_dir = check_perl_config_var('vendorlib');
    if perl_lib_install_dir is None:
        perl_lib_install_dir = "${DATADIR}/perl5";
    conf.start_msg("PERL_LIB_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_lib_install_dir), 'GREEN')
    conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir

    perl_inc = read_perl_config_var('print "@INC"')
    if '.' in perl_inc:
        perl_inc.remove('.')
    conf.start_msg("PERL_INC: ")
    conf.end_msg("%s" % (perl_inc), 'GREEN')
    conf.env.PERL_INC = perl_inc
Example #17
0
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5, 0, 0)):
    if "done" in done:
        return
    done["done"] = True
    conf.find_program("perl", var="PERL", mandatory=mandatory)
    conf.check_tool("perl")
    path_perl = conf.find_program("perl")
    conf.env.PERL_SPECIFIED = conf.env.PERL != path_perl
    conf.check_perl_version(version)

    def read_perl_config_var(cmd):
        return Utils.to_list(Utils.cmd_output([conf.env.PERL, "-MConfig", "-e", cmd]))

    def check_perl_config_var(var):
        conf.start_msg("Checking for perl $Config{{{0!s}}}:".format(var))
        try:
            v = read_perl_config_var("print $Config{{{0!s}}}".format(var))[0]
            conf.end_msg("'{0!s}'".format((v)), "GREEN")
            return v
        except IndexError:
            conf.end_msg(False, "YELLOW")
            pass
        return None

    vendor_prefix = check_perl_config_var("vendorprefix")

    perl_arch_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_arch_install_dir = check_perl_config_var("vendorarch")
    if perl_arch_install_dir is None:
        perl_arch_install_dir = "${LIBDIR}/perl5"
    conf.start_msg("PERL_ARCH_INSTALL_DIR: ")
    conf.end_msg("'{0!s}'".format((perl_arch_install_dir)), "GREEN")
    conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir

    perl_lib_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_lib_install_dir = check_perl_config_var("vendorlib")
    if perl_lib_install_dir is None:
        perl_lib_install_dir = "${DATADIR}/perl5"
    conf.start_msg("PERL_LIB_INSTALL_DIR: ")
    conf.end_msg("'{0!s}'".format((perl_lib_install_dir)), "GREEN")
    conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir

    perl_inc = read_perl_config_var('print "@INC"')
    perl_inc.remove(".")
    conf.start_msg("PERL_INC: ")
    conf.end_msg("{0!s}".format((perl_inc)), "GREEN")
    conf.env.PERL_INC = perl_inc
Example #18
0
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5,0,0)):
    if "done" in done:
        return
    done["done"] = True
    conf.find_program('perl', var='PERL', mandatory=mandatory)
    conf.check_tool('perl')
    path_perl = conf.find_program('perl')
    conf.env.PERL_SPECIFIED = (conf.env.PERL != path_perl)
    conf.check_perl_version(version)

    def read_perl_config_var(cmd):
        return Utils.to_list(Utils.cmd_output([conf.env.PERL, '-MConfig', '-e', cmd]))

    def check_perl_config_var(var):
        conf.start_msg("Checking for perl $Config{%s}:" % var)
        try:
            v = read_perl_config_var('print $Config{%s}' % var)[0]
            conf.end_msg("'%s'" % (v), 'GREEN')
            return v
        except IndexError:
            conf.end_msg(False, 'YELLOW')
            pass
        return None

    vendor_prefix = check_perl_config_var('vendorprefix')

    perl_arch_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_arch_install_dir = check_perl_config_var('vendorarch');
    if perl_arch_install_dir is None:
        perl_arch_install_dir = "${LIBDIR}/perl5";
    conf.start_msg("PERL_ARCH_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_arch_install_dir), 'GREEN')
    conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir

    perl_lib_install_dir = None
    if vendor_prefix == conf.env.PREFIX:
        perl_lib_install_dir = check_perl_config_var('vendorlib');
    if perl_lib_install_dir is None:
        perl_lib_install_dir = "${DATADIR}/perl5";
    conf.start_msg("PERL_LIB_INSTALL_DIR: ")
    conf.end_msg("'%s'" % (perl_lib_install_dir), 'GREEN')
    conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir

    perl_inc = read_perl_config_var('print "@INC"')
    perl_inc.remove('.')
    conf.start_msg("PERL_INC: ")
    conf.end_msg("%s" % (perl_inc), 'GREEN')
    conf.env.PERL_INC = perl_inc
Example #19
0
def detect(conf):
	java_path=conf.environ['PATH'].split(os.pathsep)
	v=conf.env
	if'JAVA_HOME'in conf.environ:
		java_path=[os.path.join(conf.environ['JAVA_HOME'],'bin')]+java_path
		conf.env['JAVA_HOME']=[conf.environ['JAVA_HOME']]
	for x in'javac java jar'.split():
		conf.find_program(x,var=x.upper(),path_list=java_path)
		conf.env[x.upper()]=conf.cmd_to_list(conf.env[x.upper()])
	v['JAVA_EXT']=['.java']
	if'CLASSPATH'in conf.environ:
		v['CLASSPATH']=conf.environ['CLASSPATH']
	if not v['JAR']:conf.fatal('jar is required for making java packages')
	if not v['JAVAC']:conf.fatal('javac is required for compiling java classes')
	v['JARCREATE']='cf'
def detect(conf):
	java_path=conf.environ['PATH'].split(os.pathsep)
	v=conf.env
	if'JAVA_HOME'in conf.environ:
		java_path=[os.path.join(conf.environ['JAVA_HOME'],'bin')]+java_path
		conf.env['JAVA_HOME']=[conf.environ['JAVA_HOME']]
	for x in'javac java jar'.split():
		conf.find_program(x,var=x.upper(),path_list=java_path)
		conf.env[x.upper()]=conf.cmd_to_list(conf.env[x.upper()])
	v['JAVA_EXT']=['.java']
	if'CLASSPATH'in conf.environ:
		v['CLASSPATH']=conf.environ['CLASSPATH']
	if not v['JAR']:conf.fatal('jar is required for making java packages')
	if not v['JAVAC']:conf.fatal('javac is required for compiling java classes')
	v['JARCREATE']='cf'
Example #21
0
def check_perl_version(conf, minver=None):
    """
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""
    res = True

    if not getattr(Options.options, 'perlbinary', None):
        perl = conf.find_program("perl", var="PERL")
        if not perl:
            return False
    else:
        perl = Options.options.perlbinary
        conf.env['PERL'] = perl

    version = Utils.cmd_output(perl + " -e'printf \"%vd\", $^V'")
    if not version:
        res = False
        version = "Unknown"
    elif not minver is None:
        ver = tuple(map(int, version.split(".")))
        if ver < minver:
            res = False

    if minver is None:
        cver = ""
    else:
        cver = ".".join(map(str, minver))
    conf.check_message("perl", cver, res, version)
    return res
Example #22
0
def find_cpp(conf):
    v = conf.env
    cpp = []
    if v['CPP']: cpp = v['CPP']
    elif 'CPP' in conf.environ: cpp = conf.environ['CPP']
    if not cpp: cpp = conf.find_program('cpp', var='CPP')
    v['CPP'] = cpp
Example #23
0
def get_msvc_version(conf, compiler, version, target, vcvars):
    debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
    batfile = os.path.join(conf.blddir, 'waf-print-msvc.bat')
    f = open(batfile, 'w')
    f.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
""" % (vcvars, target))
    f.close()
    sout = Utils.cmd_output(['cmd', '/E:on', '/V:on', '/C', batfile])
    lines = sout.splitlines()

    for x in ('Setting environment', 'Setting SDK environment',
              'Intel(R) C++ Compiler'):
        if lines[0].find(x) != -1:
            break
    else:
        debug('msvc: get_msvc_version: %r %r %r -> not found', compiler,
              version, target)
        conf.fatal(
            'msvc: Impossible to find a valid architecture for building (in get_msvc_version)'
        )

    for line in lines[1:]:
        if line.startswith('PATH='):
            path = line[5:]
            MSVC_PATH = path.split(';')
        elif line.startswith('INCLUDE='):
            MSVC_INCDIR = [i for i in line[8:].split(';') if i]
        elif line.startswith('LIB='):
            MSVC_LIBDIR = [i for i in line[4:].split(';') if i]

    # Check if the compiler is usable at all.
    # The detection may return 64-bit versions even on 32-bit systems, and these would fail to run.
    env = {}
    env.update(os.environ)
    env.update(PATH=path)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
    # delete CL if exists. because it could contain parameters wich can change cl's behaviour rather catastrophically.
    if env.has_key('CL'):
        del (env['CL'])

    try:
        p = pproc.Popen([cxx, '/help'],
                        env=env,
                        stdout=pproc.PIPE,
                        stderr=pproc.PIPE)
        out, err = p.communicate()
        if p.returncode != 0:
            raise Exception('return code: %r: %r' % (p.returncode, err))
    except Exception, e:
        debug('msvc: get_msvc_version: %r %r %r -> failure', compiler, version,
              target)
        debug(str(e))
        conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
Example #24
0
def check_ruby_version(conf, minver=()):
    """
    Checks if ruby is installed.
    If installed the variable RUBY will be set in environment.
    Ruby binary can be overridden by --with-ruby-binary config variable
    """
    if Options.options.rubybinary:
        ruby = Options.options.rubybinary
    else:
        ruby = conf.find_program("ruby", var="RUBY")
        if not ruby:
            return False

    conf.env['RUBY'] = ruby

    res = True

    version = Utils.cmd_output(ruby + " -e 'puts defined?(VERSION) ? VERSION : RUBY_VERSION'").strip()
    if version and minver:
        conf.env['RUBY_VERSION'] = tuple(int(x) for x in version.split("."))
        res = not (conf.env['RUBY_VERSION'] < minver)

    if not version:
        version = "Unknown"

    cver = ".".join(str(x) for x in minver)

    conf.check_message('ruby', cver, res, version)

    return res
Example #25
0
def check_perl_version(conf, minver=None):
	"""
	Checks if perl is installed.

	If installed the variable PERL will be set in environment.

	Perl binary can be overridden by --with-perl-binary config variable

	"""
	res = True

	if not getattr(Options.options, 'perlbinary', None):
		perl = conf.find_program("perl", var="PERL")
		if not perl:
			return False
	else:
		perl = Options.options.perlbinary
		conf.env['PERL'] = perl

	version = Utils.cmd_output(perl + " -e'printf \"%vd\", $^V'")
	if not version:
		res = False
		version = "Unknown"
	elif not minver is None:
		ver = tuple(map(int, version.split(".")))
		if ver < minver:
			res = False

	if minver is None:
		cver = ""
	else:
		cver = ".".join(map(str,minver))
	conf.check_message("perl", cver, res, version)
	return res
def CHECK_XSLTPROC_MANPAGES(conf):
    '''check if xsltproc can run with the given stylesheets'''


    if not conf.CONFIG_SET('XSLTPROC'):
        conf.find_program('xsltproc', var='XSLTPROC')
    if not conf.CONFIG_SET('XSLTPROC'):
        return False

    s='http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
    conf.CHECK_COMMAND('%s --nonet %s 2> /dev/null' % (conf.env.XSLTPROC, s),
                             msg='Checking for stylesheet %s' % s,
                             define='XSLTPROC_MANPAGES', on_target=False,
                             boolean=True)
    if not conf.CONFIG_SET('XSLTPROC_MANPAGES'):
        print "A local copy of the docbook.xsl wasn't found on your system" \
              " consider installing package like docbook-xsl"
Example #27
0
def detect(conf):
	python=conf.find_program('python',var='PYTHON')
	if not python:return
	v=conf.env
	v['PYCMD']='"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
	v['PYFLAGS']=''
	v['PYFLAGS_OPT']='-O'
	v['PYC']=getattr(Options.options,'pyc',1)
	v['PYO']=getattr(Options.options,'pyo',1)
Example #28
0
def detect(conf):
    python = conf.find_program('python', var='PYTHON')
    if not python: return
    v = conf.env
    v['PYCMD'] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
    v['PYFLAGS'] = ''
    v['PYFLAGS_OPT'] = '-O'
    v['PYC'] = getattr(Options.options, 'pyc', 1)
    v['PYO'] = getattr(Options.options, 'pyo', 1)
Example #29
0
def find_cpp(conf):
	v=conf.env
	cpp=None
	if v['CPP']:cpp=v['CPP']
	elif'CPP'in conf.environ:cpp=conf.environ['CPP']
	if not cpp:cpp=conf.find_program('cpp',var='CPP')
	if not cpp:cpp=v['CC']
	if not cpp:cpp=v['CXX']
	v['CPP']=cpp
Example #30
0
def find_msvc(conf):
	if sys.platform!='win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')
	v=conf.env
	compiler,version,path,includes,libdirs=detect_msvc(conf)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	has_msvc_manifest=(compiler=='msvc'and float(version)>=8)or(compiler=='wsdk'and float(version)>=6)or(compiler=='intel'and float(version)>=11)
	cxx=None
	if v.CXX:cxx=v.CXX
	elif'CXX'in conf.environ:cxx=conf.environ['CXX']
	if not cxx:cxx=conf.find_program(compiler_name,var='CXX',path_list=path,mandatory=True)
	cxx=conf.cmd_to_list(cxx)
	env=dict(conf.environ)
	env.update(PATH=';'.join(path))
	if not Utils.cmd_output([cxx,'/nologo','/?'],silent=True,env=env):
		conf.fatal('the msvc compiler could not be identified')
	link=v.LINK_CXX
	if not link:
		link=conf.find_program(linker_name,path_list=path,mandatory=True)
	ar=v.AR
	if not ar:
		ar=conf.find_program(lib_name,path_list=path,mandatory=True)
	mt=v.MT
	if has_msvc_manifest:
		mt=conf.find_program('MT',path_list=path,mandatory=True)
	v.MSVC_MANIFEST=has_msvc_manifest
	v.PATH=path
	v.CPPPATH=includes
	v.LIBPATH=libdirs
	v.CC=v.CXX=cxx
	v.CC_NAME=v.CXX_NAME='msvc'
	v.LINK=v.LINK_CXX=link
	if not v.LINK_CC:
		v.LINK_CC=v.LINK_CXX
	v.AR=ar
	v.MT=mt
	v.MTFLAGS=v.ARFLAGS=['/NOLOGO']
	conf.check_tool('winres')
	if not conf.env.WINRC:
		warn('Resource compiler not found. Compiling resource file is disabled')
	try:v.prepend_value('CPPPATH',conf.environ['INCLUDE'])
	except KeyError:pass
	try:v.prepend_value('LIBPATH',conf.environ['LIB'])
	except KeyError:pass
def detect(conf):
    python = conf.find_program("python", var="PYTHON")
    if not python:
        return
    v = conf.env
    v["PYCMD"] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
    v["PYFLAGS"] = ""
    v["PYFLAGS_OPT"] = "-O"
    v["PYC"] = getattr(Options.options, "pyc", 1)
    v["PYO"] = getattr(Options.options, "pyo", 1)
def find_msvc(conf):
	if sys.platform!='win32':
		conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet')
	v=conf.env
	compiler,path,includes,libdirs=detect_msvc(conf)
	v['PATH']=path
	v['CPPPATH']=includes
	v['LIBPATH']=libdirs
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	cxx=None
	if v['CXX']:cxx=v['CXX']
	elif'CXX'in conf.environ:cxx=conf.environ['CXX']
	if not cxx:cxx=conf.find_program(compiler_name,var='CXX',path_list=path)
	if not cxx:conf.fatal('%s was not found (compiler)'%compiler_name)
	cxx=conf.cmd_to_list(cxx)
	env=dict(conf.environ)
	env.update(PATH=';'.join(path))
	if not Utils.cmd_output([cxx,'/nologo','/?'],silent=True,env=env):
		conf.fatal('the msvc compiler could not be identified')
	v['CC']=v['CXX']=cxx
	v['CC_NAME']=v['CXX_NAME']='msvc'
	try:v.prepend_value('CPPPATH',conf.environ['INCLUDE'])
	except KeyError:pass
	try:v.prepend_value('LIBPATH',conf.environ['LIB'])
	except KeyError:pass
	if not v['LINK_CXX']:
		link=conf.find_program(linker_name,path_list=path)
		if link:v['LINK_CXX']=link
		else:conf.fatal('%s was not found (linker)'%linker_name)
	v['LINK']=link
	if not v['LINK_CC']:v['LINK_CC']=v['LINK_CXX']
	if not v['AR']:
		stliblink=conf.find_program(lib_name,path_list=path)
		if not stliblink:return
		v['AR']=stliblink
		v['ARFLAGS']=['/NOLOGO']
	manifesttool=conf.find_program('MT',path_list=path)
	if manifesttool:
		v['MT']=manifesttool
		v['MTFLAGS']=['/NOLOGO']
	conf.check_tool('winres')
	if not conf.env['WINRC']:
		warn('Resource compiler not found. Compiling resource file is disabled')
Example #33
0
def get_msvc_version(conf, compiler, version, target, vcvars):
    debug("msvc: get_msvc_version: " + compiler + " " + version + " " + target + " ...")
    batfile = os.path.join(conf.blddir, "waf-print-msvc.bat")
    f = open(batfile, "w")
    f.write(
        """@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
"""
        % (vcvars, target)
    )
    f.close()
    sout = Utils.cmd_output(["cmd", "/E:on", "/V:on", "/C", batfile])
    lines = sout.splitlines()

    for x in ("Setting environment", "Setting SDK environment", "Intel(R) C++ Compiler"):
        if lines[0].find(x) != -1:
            break
    else:
        debug("msvc: get_msvc_version: %r %r %r -> not found" % (compiler, version, target))
        conf.fatal("msvc: Impossible to find a valid architecture for building (in get_msvc_version)")

    for line in lines[1:]:
        if line.startswith("PATH="):
            path = line[5:]
            MSVC_PATH = path.split(";")
        elif line.startswith("INCLUDE="):
            MSVC_INCDIR = [i for i in line[8:].split(";") if i]
        elif line.startswith("LIB="):
            MSVC_LIBDIR = [i for i in line[4:].split(";") if i]

            # Check if the compiler is usable at all.
            # The detection may return 64-bit versions even on 32-bit systems, and these would fail to run.
    env = {}
    env.update(os.environ)
    env.update(PATH=path)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
    # delete CL if exists. because it could contain parameters wich can change cl's behaviour rather catastrophically.
    if env.has_key("CL"):
        del (env["CL"])

    try:
        p = pproc.Popen([cxx, "/help"], env=env, stdout=pproc.PIPE, stderr=pproc.PIPE)
        out, err = p.communicate()
        if p.returncode != 0:
            raise Exception("return code: %r: %r" % (p.returncode, err))
    except Exception, e:
        debug("msvc: get_msvc_version: %r %r %r -> failure" % (compiler, version, target))
        debug(str(e))
        conf.fatal("msvc: cannot run the compiler (in get_msvc_version)")
Example #34
0
def check_perl_version(conf, minver=None):
    if getattr(Options.options, 'perlbinary', None):
        conf.env.PERL = Options.options.perlbinary
    else:
        conf.find_program('perl', var='PERL', mandatory=True)
    try:
        version = Utils.cmd_output([conf.env.PERL, '-e', 'printf "%vd",$^V'])
    except:
        conf.fatal('could not determine the perl version')
    conf.env.PERL_VERSION = version
    cver = ''
    if minver:
        try:
            ver = tuple(map(int, version.split('.')))
        except:
            conf.fatal('unsupported perl version %r' % version)
        if ver < minver:
            conf.fatal('perl is too old')
        cver = '.'.join(map(str, minver))
    conf.check_message('perl', cver, True, version)
Example #35
0
File: perl.py Project: NKSG/ns3
def check_perl_version(conf,minver=None):
	if getattr(Options.options,'perlbinary',None):
		conf.env.PERL=Options.options.perlbinary
	else:
		conf.find_program('perl',var='PERL',mandatory=True)
	try:
		version=Utils.cmd_output([conf.env.PERL,'-e','printf "%vd",$^V'])
	except:
		conf.fatal('could not determine the perl version')
	conf.env.PERL_VERSION=version
	cver=''
	if minver:
		try:
			ver=tuple(map(int,version.split('.')))
		except:
			conf.fatal('unsupported perl version %r'%version)
		if ver<minver:
			conf.fatal('perl is too old')
		cver='.'.join(map(str,minver))
	conf.check_message('perl',cver,True,version)
Example #36
0
def get_msvc_version(conf, compiler, version, target, vcvars):
    debug('msvc: get_msvc_version: ' + compiler + ' ' + version + ' ' +
          target + ' ...')
    batfile = os.path.join(conf.blddir, 'waf-print-msvc.bat')
    f = open(batfile, 'w')
    f.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
""" % (vcvars, target))
    f.close()
    sout = Utils.cmd_output(['cmd', '/E:on', '/V:on', '/C', batfile])
    lines = sout.splitlines()
    for x in ('Setting environment', 'Setting SDK environment',
              'Intel(R) C++ Compiler'):
        if lines[0].find(x) != -1:
            break
    else:
        debug('msvc: get_msvc_version: %r %r %r -> not found' %
              (compiler, version, target))
        conf.fatal(
            'msvc: Impossible to find a valid architecture for building (in get_msvc_version)'
        )
    for line in lines[1:]:
        if line.startswith('PATH='):
            path = line[5:]
            MSVC_PATH = path.split(';')
        elif line.startswith('INCLUDE='):
            MSVC_INCDIR = [i for i in line[8:].split(';') if i]
        elif line.startswith('LIB='):
            MSVC_LIBDIR = [i for i in line[4:].split(';') if i]
    env = {}
    env.update(os.environ)
    env.update(PATH=path)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
    if env.has_key('CL'):
        del (env['CL'])
    try:
        p = pproc.Popen([cxx, '/help'],
                        env=env,
                        stdout=pproc.PIPE,
                        stderr=pproc.PIPE)
        out, err = p.communicate()
        if p.returncode != 0:
            raise Exception('return code: %r: %r' % (p.returncode, err))
    except Exception, e:
        debug('msvc: get_msvc_version: %r %r %r -> failure' %
              (compiler, version, target))
        debug(str(e))
        conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
Example #37
0
def check_ruby_version(conf,minver=()):
	if Options.options.rubybinary:
		conf.env.RUBY=Options.options.rubybinary
	else:
		conf.find_program("ruby",var="RUBY",mandatory=True)
	ruby=conf.env.RUBY
	try:
		version=Utils.cmd_output([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION=version
	try:
		ver=tuple(map(int,version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r'%version)
	cver=''
	if minver:
		if ver<minver:
			conf.fatal('ruby is too old')
		cver=".".join([str(x)for x in minver])
	conf.check_message('ruby',cver,True,version)
Example #38
0
def detect(conf):
    if not conf.env.PYTHON:
        conf.env.PYTHON = sys.executable
    python = conf.find_program("python", var="PYTHON")
    if not python:
        conf.fatal("Could not find the path of the python executable")
    v = conf.env
    v["PYCMD"] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
    v["PYFLAGS"] = ""
    v["PYFLAGS_OPT"] = "-O"
    v["PYC"] = getattr(Options.options, "pyc", 1)
    v["PYO"] = getattr(Options.options, "pyo", 1)
Example #39
0
def detect(conf):
    if not conf.env.PYTHON:
        conf.env.PYTHON = sys.executable
    python = conf.find_program('python', var='PYTHON')
    if not python:
        conf.fatal('Could not find the path of the python executable')
    v = conf.env
    v['PYCMD'] = '"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
    v['PYFLAGS'] = ''
    v['PYFLAGS_OPT'] = '-O'
    v['PYC'] = getattr(Options.options, 'pyc', 1)
    v['PYO'] = getattr(Options.options, 'pyo', 1)
Example #40
0
File: ruby.py Project: NKSG/ns3
def check_ruby_version(conf,minver=()):
	if Options.options.rubybinary:
		conf.env.RUBY=Options.options.rubybinary
	else:
		conf.find_program("ruby",var="RUBY",mandatory=True)
	ruby=conf.env.RUBY
	try:
		version=Utils.cmd_output([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
	except:
		conf.fatal('could not determine ruby version')
	conf.env.RUBY_VERSION=version
	try:
		ver=tuple(map(int,version.split(".")))
	except:
		conf.fatal('unsupported ruby version %r'%version)
	cver=''
	if minver:
		if ver<minver:
			conf.fatal('ruby is too old')
		cver=".".join(str(x)for x in minver)
	conf.check_message('ruby',cver,True,version)
Example #41
0
def detect(conf):
	if not conf.env.PYTHON:
		conf.env.PYTHON=sys.executable
	python=conf.find_program('python',var='PYTHON')
	if not python:
		conf.fatal('Could not find the path of the python executable')
	v=conf.env
	v['PYCMD']='"import sys, py_compile;py_compile.compile(sys.argv[1], sys.argv[2])"'
	v['PYFLAGS']=''
	v['PYFLAGS_OPT']='-O'
	v['PYC']=getattr(Options.options,'pyc',1)
	v['PYO']=getattr(Options.options,'pyo',1)
Example #42
0
File: msvc.py Project: runt18/samba
def get_msvc_version(conf, compiler, version, target, vcvars):
	debug('msvc: get_msvc_version: %r %r %r', compiler, version, target)
	batfile = os.path.join(conf.blddir, 'waf-print-msvc.bat')
	f = open(batfile, 'w')
	f.write("""@echo off
set INCLUDE=
set LIB=
call "{0!s}" {1!s}
echo PATH=%PATH%
echo INCLUDE=%INCLUDE%
echo LIB=%LIB%
""".format(vcvars, target))
	f.close()
	sout = Utils.cmd_output(['cmd', '/E:on', '/V:on', '/C', batfile])
	lines = sout.splitlines()

	for x in ('Setting environment', 'Setting SDK environment', 'Intel(R) C++ Compiler'):
		if lines[0].find(x) != -1:
			break
	else:
		debug('msvc: get_msvc_version: %r %r %r -> not found', compiler, version, target)
		conf.fatal('msvc: Impossible to find a valid architecture for building (in get_msvc_version)')

	for line in lines[1:]:
		if line.startswith('PATH='):
			path = line[5:]
			MSVC_PATH = path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR = [i for i in line[8:].split(';') if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR = [i for i in line[4:].split(';') if i]

	# Check if the compiler is usable at all.
	# The detection may return 64-bit versions even on 32-bit systems, and these would fail to run.
	env = {}
	env.update(os.environ)
	env.update(PATH = path)
	compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
	cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
	# delete CL if exists. because it could contain parameters wich can change cl's behaviour rather catastrophically.
	if env.has_key('CL'):
		del(env['CL'])

	try:
		p = pproc.Popen([cxx, '/help'], env=env, stdout=pproc.PIPE, stderr=pproc.PIPE)
		out, err = p.communicate()
		if p.returncode != 0:
			raise Exception('return code: {0!r}: {1!r}'.format(p.returncode, err))
	except Exception, e:
		debug('msvc: get_msvc_version: %r %r %r -> failure', compiler, version, target)
		debug(str(e))
		conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
Example #43
0
def detect(conf):
    # If JAVA_PATH is set, we prepend it to the path list
    java_path = conf.environ["PATH"].split(os.pathsep)
    v = conf.env

    if "JAVA_HOME" in conf.environ:
        java_path = [os.path.join(conf.environ["JAVA_HOME"], "bin")] + java_path
        conf.env["JAVA_HOME"] = [conf.environ["JAVA_HOME"]]

    for x in "javac java jar".split():
        conf.find_program(x, var=x.upper(), path_list=java_path)
        conf.env[x.upper()] = conf.cmd_to_list(conf.env[x.upper()])
    v["JAVA_EXT"] = [".java"]

    if "CLASSPATH" in conf.environ:
        v["CLASSPATH"] = conf.environ["CLASSPATH"]

    if not v["JAR"]:
        conf.fatal("jar is required for making java packages")
    if not v["JAVAC"]:
        conf.fatal("javac is required for compiling java classes")
    v["JARCREATE"] = "cf"  # can use cvf
Example #44
0
def find_cpp(conf):
    v = conf.env
    cpp = None
    if v["CPP"]:
        cpp = v["CPP"]
    elif "CPP" in conf.environ:
        cpp = conf.environ["CPP"]
    if not cpp:
        cpp = conf.find_program("cpp", var="CPP")
    if not cpp:
        cpp = v["CC"]
    if not cpp:
        cpp = v["CXX"]
    v["CPP"] = cpp
Example #45
0
def get_msvc_version(conf,compiler,version,target,vcvars):
	debug('msvc: get_msvc_version: %r %r %r',compiler,version,target)
	batfile=os.path.join(conf.blddir,'waf-print-msvc.bat')
	f=open(batfile,'w')
	f.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
"""%(vcvars,target))
	f.close()
	sout=Utils.cmd_output(['cmd','/E:on','/V:on','/C',batfile])
	lines=sout.splitlines()
	for x in('Setting environment','Setting SDK environment','Intel(R) C++ Compiler'):
		if lines[0].find(x)!=-1:
			break
	else:
		debug('msvc: get_msvc_version: %r %r %r -> not found',compiler,version,target)
		conf.fatal('msvc: Impossible to find a valid architecture for building (in get_msvc_version)')
	for line in lines[1:]:
		if line.startswith('PATH='):
			path=line[5:]
			MSVC_PATH=path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR=[i for i in line[8:].split(';')if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR=[i for i in line[4:].split(';')if i]
	env={}
	env.update(os.environ)
	env.update(PATH=path)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	cxx=conf.find_program(compiler_name,path_list=MSVC_PATH)
	if env.has_key('CL'):
		del(env['CL'])
	try:
		p=pproc.Popen([cxx,'/help'],env=env,stdout=pproc.PIPE,stderr=pproc.PIPE)
		out,err=p.communicate()
		if p.returncode!=0:
			raise Exception('return code: %r: %r'%(p.returncode,err))
	except Exception as e:
		debug('msvc: get_msvc_version: %r %r %r -> failure',compiler,version,target)
		debug(str(e))
		conf.fatal('msvc: cannot run the compiler (in get_msvc_version)')
	else:
		debug('msvc: get_msvc_version: %r %r %r -> OK',compiler,version,target)
	return(MSVC_PATH,MSVC_INCDIR,MSVC_LIBDIR)
Example #46
0
def get_msvc_version(conf, compiler, version, target, vcvars):
    debug('msvc: get_msvc_version: ' + compiler + ' ' + version + ' ' +
          target + ' ...')
    batfile = os.path.join(conf.blddir, "waf-print-msvc.bat")
    f = open(batfile, 'w')
    f.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
""" % (vcvars, target))
    f.close()
    sout = Utils.cmd_output(['cmd', '/E:on', '/V:on', '/C', batfile])
    lines = sout.splitlines()
    if lines[0].find("Setting environment") == -1 and lines[0].find(
            "Setting SDK environment") == -1 and lines[1].find(
                'Intel(R) C++ Compiler') == -1:
        debug('msvc: get_msvc_version: ' + compiler + ' ' + version + ' ' +
              target + ' -> not found')
        conf.fatal(
            'msvc: Impossible to find a valid architecture for building (in get_msvc_version)'
        )
    for line in lines[1:]:
        if line.startswith('PATH='):
            path = line[5:]
            MSVC_PATH = path.split(';')
        elif line.startswith('INCLUDE='):
            MSVC_INCDIR = [i for i in line[8:].split(';') if i]
        elif line.startswith('LIB='):
            MSVC_LIBDIR = [i for i in line[4:].split(';') if i]
    env = {}
    env.update(os.environ)
    env.update(PATH=path)
    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    cxx = conf.find_program(compiler_name, path_list=MSVC_PATH)
    import pproc
    try:
        p = pproc.Popen([cxx], env=env, stdout=pproc.PIPE, stderr=pproc.PIPE)
        out, err = p.communicate()
        if p.returncode != 0:
            raise Exception('return code: ' + str(p.returncode) + ': ' + err)
    except Exception, e:
        print('msvc: get_msvc_version: ' + compiler + ' ' + version + ' ' +
              target + ' -> failed: ' + str(e))
        conf.fatal('msvc: Compiler is not runnable (in get_msvc_version)')
Example #47
0
def detect(conf):
	java_path=os.environ['PATH'].split(os.pathsep)
	v=conf.env
	if os.environ.has_key('JAVA_HOME'):
		java_path=[os.path.join(os.environ['JAVA_HOME'],'bin')]+java_path
		conf.env['JAVA_HOME']=os.environ['JAVA_HOME']
	conf.find_program('javac',var='JAVAC',path_list=java_path)
	conf.find_program('java',var='JAVA',path_list=java_path)
	conf.find_program('jar',var='JAR',path_list=java_path)
	v['JAVA_EXT']=['.java']
	if os.environ.has_key('CLASSPATH'):
		v['CLASSPATH']=os.environ['CLASSPATH']
	if not v['JAR']:conf.fatal('jar is required for making java packages')
	if not v['JAVAC']:conf.fatal('javac is required for compiling java classes')
	v['JARCREATE']='cf'
Example #48
0
def get_msvc_version(conf,compiler,version,target,vcvars):
	debug('msvc: get_msvc_version: '+compiler+' '+version+' '+target+' ...')
	batfile=os.path.join(conf.blddir,"waf-print-msvc.bat")
	f=open(batfile,'w')
	f.write("""@echo off
set INCLUDE=
set LIB=
call "%s" %s
echo PATH=%%PATH%%
echo INCLUDE=%%INCLUDE%%
echo LIB=%%LIB%%
"""%(vcvars,target))
	f.close()
	sout=Utils.cmd_output(['cmd','/E:on','/V:on','/C',batfile])
	lines=sout.splitlines()
	if lines[0].find("Setting environment")==-1 and lines[0].find("Setting SDK environment")==-1 and lines[1].find('Intel(R) C++ Compiler')==-1:
		debug('msvc: get_msvc_version: '+compiler+' '+version+' '+target+' -> not found')
		conf.fatal('msvc: Impossible to find a valid architecture for building (in get_msvc_version)')
	for line in lines[1:]:
		if line.startswith('PATH='):
			path=line[5:]
			MSVC_PATH=path.split(';')
		elif line.startswith('INCLUDE='):
			MSVC_INCDIR=[i for i in line[8:].split(';')if i]
		elif line.startswith('LIB='):
			MSVC_LIBDIR=[i for i in line[4:].split(';')if i]
	env={}
	env.update(os.environ)
	env.update(PATH=path)
	compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler)
	cxx=conf.find_program(compiler_name,path_list=MSVC_PATH)
	import pproc
	try:
		p=pproc.Popen([cxx],env=env,stdout=pproc.PIPE,stderr=pproc.PIPE)
		out,err=p.communicate()
		if p.returncode!=0:
			raise Exception('return code: '+str(p.returncode)+': '+err)
	except Exception,e:
		print('msvc: get_msvc_version: '+compiler+' '+version+' '+target+' -> failed: '+str(e))
		conf.fatal('msvc: Compiler is not runnable (in get_msvc_version)')
Example #49
0
def check_perl_version(conf,minver=None):
	res=True
	if not getattr(Options.options,'perlbinary',None):
		perl=conf.find_program("perl",var="PERL")
		if not perl:
			return False
	else:
		perl=Options.options.perlbinary
		conf.env['PERL']=perl
	version=Utils.cmd_output(perl+" -e'printf \"%vd\", $^V'")
	if not version:
		res=False
		version="Unknown"
	elif not minver is None:
		ver=tuple(map(int,version.split(".")))
		if ver<minver:
			res=False
	if minver is None:
		cver=""
	else:
		cver=".".join(map(str,minver))
	conf.check_message("perl",cver,res,version)
	return res
Example #50
0
def find_msvc(conf):
    # due to path format limitations, limit operation only to native Win32. Yeah it sucks.
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )

    v = conf.env

    compiler, version, path, includes, libdirs = detect_msvc(conf)

    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or (
        compiler == 'wsdk'
        and float(version) >= 6) or (compiler == 'intel'
                                     and float(version) >= 11)

    # compiler
    cxx = None
    if v.CXX: cxx = v.CXX
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name,
                                var='CXX',
                                path_list=path,
                                mandatory=True)
    cxx = conf.cmd_to_list(cxx)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')

    link = v.LINK_CXX
    if not link:
        link = conf.find_program(linker_name, path_list=path, mandatory=True)
    ar = v.AR
    if not ar:
        ar = conf.find_program(lib_name, path_list=path, mandatory=True)

    # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
    mt = v.MT
    if has_msvc_manifest:
        mt = conf.find_program('MT', path_list=path, mandatory=True)

    # no more possibility of failure means the data state will be consistent
    # we may store the data safely now

    v.MSVC_MANIFEST = has_msvc_manifest
    v.PATH = path
    v.CPPPATH = includes
    v.LIBPATH = libdirs

    # c/c++ compiler
    v.CC = v.CXX = cxx
    v.CC_NAME = v.CXX_NAME = 'msvc'

    v.LINK = v.LINK_CXX = link
    if not v.LINK_CC:
        v.LINK_CC = v.LINK_CXX

    v.AR = ar
    v.MT = mt
    v.MTFLAGS = v.ARFLAGS = ['/NOLOGO']

    conf.check_tool('winres')

    if not conf.env.WINRC:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')

    # environment flags
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass
Example #51
0
def detect(conf):
    conf.find_program('gcj', var='GCJ')
    conf.env['GCJLINK'] = conf.env['GCJ']
Example #52
0
def check_python_headers(conf):
    if not conf.env['CC_NAME'] and not conf.env['CXX_NAME']:
        conf.fatal('load a compiler first (gcc, g++, ..)')
    if not conf.env['PYTHON_VERSION']:
        conf.check_python_version()
    env = conf.env
    python = env['PYTHON']
    assert python, ("python is %r !" % (python, ))
    if Options.platform == 'darwin':
        conf.check_tool('osx')
    try:
        v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split(
        )
        (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS,
         python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY,
         Py_ENABLE_SHARED,
         python_MACOSX_DEPLOYMENT_TARGET) = _get_python_variables(
             python, ["get_config_var('%s')" % x for x in v],
             ['from distutils.sysconfig import get_config_var'])
    except RuntimeError:
        conf.fatal("Python development headers not found (-v for details).")
    conf.log.write("""Configuration returned from %r:
python_prefix = %r
python_SO = %r
python_SYSLIBS = %r
python_LDFLAGS = %r
python_SHLIBS = %r
python_LIBDIR = %r
python_LIBPL = %r
INCLUDEPY = %r
Py_ENABLE_SHARED = %r
MACOSX_DEPLOYMENT_TARGET = %r
""" % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS,
       python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED,
       python_MACOSX_DEPLOYMENT_TARGET))
    if python_MACOSX_DEPLOYMENT_TARGET:
        conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
        conf.environ[
            'MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
    env['pyext_PATTERN'] = '%s' + python_SO
    if python_SYSLIBS is not None:
        for lib in python_SYSLIBS.split():
            if lib.startswith('-l'):
                lib = lib[2:]
            env.append_value('LIB_PYEMBED', lib)
    if python_SHLIBS is not None:
        for lib in python_SHLIBS.split():
            if lib.startswith('-l'):
                lib = lib[2:]
            env.append_value('LIB_PYEMBED', lib)
    if Options.platform != 'darwin' and python_LDFLAGS:
        env.append_value('LINKFLAGS_PYEMBED', python_LDFLAGS.split())
    result = False
    name = 'python' + env['PYTHON_VERSION']
    if python_LIBDIR is not None:
        path = [python_LIBDIR]
        conf.log.write("\n\n# Trying LIBDIR: %r\n" % path)
        result = conf.check(lib=name, uselib='PYEMBED', libpath=path)
    if not result and python_LIBPL is not None:
        conf.log.write(
            "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n"
        )
        path = [python_LIBPL]
        result = conf.check(lib=name, uselib='PYEMBED', libpath=path)
    if not result:
        conf.log.write(
            "\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n"
        )
        path = [os.path.join(python_prefix, "libs")]
        name = 'python' + env['PYTHON_VERSION'].replace('.', '')
        result = conf.check(lib=name, uselib='PYEMBED', libpath=path)
    if result:
        env['LIBPATH_PYEMBED'] = path
        env.append_value('LIB_PYEMBED', name)
    else:
        conf.log.write("\n\n### LIB NOT FOUND\n")
    if (sys.platform == 'win32' or sys.platform.startswith('os2')
            or sys.platform == 'darwin' or Py_ENABLE_SHARED):
        env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED']
        env['LIB_PYEXT'] = env['LIB_PYEMBED']
    python_config = conf.find_program(
        'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])),
        var='PYTHON_CONFIG')
    if not python_config:
        python_config = conf.find_program(
            'python-config-%s' %
            ('.'.join(env['PYTHON_VERSION'].split('.')[:2])),
            var='PYTHON_CONFIG')
    includes = []
    if python_config:
        for incstr in Utils.cmd_output("%s --includes" %
                                       (python_config)).strip().split():
            if (incstr.startswith('-I') or incstr.startswith('/I')):
                incstr = incstr[2:]
            if incstr not in includes:
                includes.append(incstr)
        conf.log.write("Include path for Python extensions "
                       "(found via python-config --includes): %r\n" %
                       (includes, ))
        env['CPPPATH_PYEXT'] = includes
        env['CPPPATH_PYEMBED'] = includes
    else:
        conf.log.write("Include path for Python extensions "
                       "(found via distutils module): %r\n" % (INCLUDEPY, ))
        env['CPPPATH_PYEXT'] = [INCLUDEPY]
        env['CPPPATH_PYEMBED'] = [INCLUDEPY]
    if env['CC_NAME'] == 'gcc':
        env.append_value('CCFLAGS_PYEMBED', '-fno-strict-aliasing')
        env.append_value('CCFLAGS_PYEXT', '-fno-strict-aliasing')
    if env['CXX_NAME'] == 'gcc':
        env.append_value('CXXFLAGS_PYEMBED', '-fno-strict-aliasing')
        env.append_value('CXXFLAGS_PYEXT', '-fno-strict-aliasing')
    test_env = env.copy()
    a = test_env.append_value
    a('CPPPATH', env['CPPPATH_PYEMBED'])
    a('LIBPATH', env['LIBPATH_PYEMBED'])
    a('LIB', env['LIB_PYEMBED'])
    a('LINKFLAGS', env['LINKFLAGS_PYEMBED'])
    a('CXXFLAGS', env['CXXFLAGS_PYEMBED'])
    a('CCFLAGS', env['CCFLAGS_PYEMBED'])
    conf.check(header_name='Python.h',
               define_name='HAVE_PYTHON_H',
               env=test_env,
               fragment=FRAG_2,
               errmsg='Could not find the python development headers',
               mandatory=1)
Example #53
0
def detect(conf):
	swig = conf.find_program('swig', var='SWIG', mandatory=True)
Example #54
0
def check_python_headers(conf, mandatory=True):
    """Check for headers and libraries necessary to extend or embed python.

	On success the environment variables xxx_PYEXT and xxx_PYEMBED are added for uselib

	PYEXT: for compiling python extensions
	PYEMBED: for embedding a python interpreter"""

    if not conf.env['CC_NAME'] and not conf.env['CXX_NAME']:
        conf.fatal('load a compiler first (gcc, g++, ..)')

    if not conf.env['PYTHON_VERSION']:
        conf.check_python_version()

    env = conf.env
    python = env['PYTHON']
    if not python:
        conf.fatal('could not find the python executable')

    ## On Mac OSX we need to use mac bundles for python plugins
    if Options.platform == 'darwin':
        conf.check_tool('osx')

    try:
        # Get some python configuration variables using distutils
        v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split(
        )
        (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS,
         python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED,
         python_MACOSX_DEPLOYMENT_TARGET) = \
         _get_python_variables(python, ["get_config_var('%s') or ''" % x for x in v],
                 ['from distutils.sysconfig import get_config_var'])
    except RuntimeError:
        conf.fatal("Python development headers not found (-v for details).")

    conf.log.write("""Configuration returned from %r:
python_prefix = %r
python_SO = %r
python_SYSLIBS = %r
python_LDFLAGS = %r
python_SHLIBS = %r
python_LIBDIR = %r
python_LIBPL = %r
INCLUDEPY = %r
Py_ENABLE_SHARED = %r
MACOSX_DEPLOYMENT_TARGET = %r
""" % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS,
       python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED,
       python_MACOSX_DEPLOYMENT_TARGET))

    # Allow some python overrides from env vars for cross-compiling
    os_env = dict(os.environ)

    override_python_LDFLAGS = os_env.get('python_LDFLAGS', None)
    if override_python_LDFLAGS is not None:
        conf.log.write("python_LDFLAGS override from environment = %r\n" %
                       (override_python_LDFLAGS))
        python_LDFLAGS = override_python_LDFLAGS

    override_python_LIBDIR = os_env.get('python_LIBDIR', None)
    if override_python_LIBDIR is not None:
        conf.log.write("python_LIBDIR override from environment = %r\n" %
                       (override_python_LIBDIR))
        python_LIBDIR = override_python_LIBDIR

    if python_MACOSX_DEPLOYMENT_TARGET:
        conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET
        conf.environ[
            'MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET

    env['pyext_PATTERN'] = '%s' + python_SO

    # Check for python libraries for embedding
    if python_SYSLIBS is not None:
        for lib in python_SYSLIBS.split():
            if lib.startswith('-l'):
                lib = lib[2:]  # strip '-l'
            env.append_value('LIB_PYEMBED', lib)

    if python_SHLIBS is not None:
        for lib in python_SHLIBS.split():
            if lib.startswith('-l'):
                env.append_value('LIB_PYEMBED', lib[2:])  # strip '-l'
            else:
                env.append_value('LINKFLAGS_PYEMBED', lib)

    if Options.platform != 'darwin' and python_LDFLAGS:
        parse_flags(python_LDFLAGS, 'PYEMBED', env)

    result = False
    name = 'python' + env['PYTHON_VERSION']

    if python_LIBDIR is not None:
        path = [python_LIBDIR]
        conf.log.write("\n\n# Trying LIBDIR: %r\n" % path)
        result = conf.check(lib=name, uselib='PYEMBED', libpath=path)

    if not result and python_LIBPL is not None:
        conf.log.write(
            "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n"
        )
        path = [python_LIBPL]
        result = conf.check(lib=name, uselib='PYEMBED', libpath=path)

    if not result:
        conf.log.write(
            "\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n"
        )
        path = [os.path.join(python_prefix, "libs")]
        name = 'python' + env['PYTHON_VERSION'].replace('.', '')
        result = conf.check(lib=name, uselib='PYEMBED', libpath=path)

    if result:
        env['LIBPATH_PYEMBED'] = path
        env.append_value('LIB_PYEMBED', name)
    else:
        conf.log.write("\n\n### LIB NOT FOUND\n")

    # under certain conditions, python extensions must link to
    # python libraries, not just python embedding programs.
    if (sys.platform == 'win32' or sys.platform.startswith('os2')
            or sys.platform == 'darwin' or Py_ENABLE_SHARED):
        env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED']
        env['LIB_PYEXT'] = env['LIB_PYEMBED']

    # We check that pythonX.Y-config exists, and if it exists we
    # use it to get only the includes, else fall back to distutils.
    python_config = conf.find_program(
        'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])),
        var='PYTHON_CONFIG')
    if not python_config:
        python_config = conf.find_program(
            'python-config-%s' %
            ('.'.join(env['PYTHON_VERSION'].split('.')[:2])),
            var='PYTHON_CONFIG')

    includes = []
    if python_config:
        for incstr in Utils.cmd_output("%s --includes" %
                                       (python_config, )).strip().split():
            # strip the -I or /I
            if (incstr.startswith('-I') or incstr.startswith('/I')):
                incstr = incstr[2:]
            # append include path, unless already given
            if incstr not in includes:
                includes.append(incstr)
        conf.log.write("Include path for Python extensions "
                       "(found via python-config --includes): %r\n" %
                       (includes, ))
        env['CPPPATH_PYEXT'] = includes
        env['CPPPATH_PYEMBED'] = includes
    else:
        conf.log.write("Include path for Python extensions "
                       "(found via distutils module): %r\n" % (INCLUDEPY, ))
        env['CPPPATH_PYEXT'] = [INCLUDEPY]
        env['CPPPATH_PYEMBED'] = [INCLUDEPY]

    # Code using the Python API needs to be compiled with -fno-strict-aliasing
    if env['CC_NAME'] == 'gcc':
        env.append_value('CCFLAGS_PYEMBED', '-fno-strict-aliasing')
        env.append_value('CCFLAGS_PYEXT', '-fno-strict-aliasing')
    if env['CXX_NAME'] == 'gcc':
        env.append_value('CXXFLAGS_PYEMBED', '-fno-strict-aliasing')
        env.append_value('CXXFLAGS_PYEXT', '-fno-strict-aliasing')

    # See if it compiles
    conf.check(define_name='HAVE_PYTHON_H',
               uselib='PYEMBED',
               fragment=FRAG_2,
               errmsg='Could not find the python development headers',
               mandatory=mandatory)
Example #55
0
def find_msvc(conf):
    # due to path format limitations, limit operation only to native Win32. Yeah it sucks.
    if sys.platform != 'win32':
        conf.fatal(
            'MSVC module only works under native Win32 Python! cygwin is not supported yet'
        )

    v = conf.env

    compiler, path, includes, libdirs = detect_msvc(conf)
    v['PATH'] = path
    v['CPPPATH'] = includes
    v['LIBPATH'] = libdirs

    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)

    # compiler
    cxx = None
    if v['CXX']: cxx = v['CXX']
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    if not cxx:
        cxx = conf.find_program(compiler_name, var='CXX', path_list=path)
    if not cxx: conf.fatal('%s was not found (compiler)' % compiler_name)
    cxx = conf.cmd_to_list(cxx)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    env.update(PATH=';'.join(path))
    if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env):
        conf.fatal('the msvc compiler could not be identified')

    # c/c++ compiler
    v['CC'] = v['CXX'] = cxx
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'

    # environment flags
    try:
        v.prepend_value('CPPPATH', conf.environ['INCLUDE'])
    except KeyError:
        pass
    try:
        v.prepend_value('LIBPATH', conf.environ['LIB'])
    except KeyError:
        pass

    # linker
    if not v['LINK_CXX']:
        link = conf.find_program(linker_name, path_list=path)
        if link: v['LINK_CXX'] = link
        else: conf.fatal('%s was not found (linker)' % linker_name)
    v['LINK'] = link

    if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX']

    # staticlib linker
    if not v['AR']:
        stliblink = conf.find_program(lib_name, path_list=path)
        if not stliblink: return
        v['AR'] = stliblink
        v['ARFLAGS'] = ['/NOLOGO']

    # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
    manifesttool = conf.find_program('MT', path_list=path)
    if manifesttool:
        v['MT'] = manifesttool
        v['MTFLAGS'] = ['/NOLOGO']

    conf.check_tool('winres')

    if not conf.env['WINRC']:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')