summaryrefslogtreecommitdiff
path: root/third_party/waf/wafadmin/Tools/compiler_cc.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2015-03-25 11:13:40 +0000
committerJeremy Allison <jra@samba.org>2015-03-26 22:47:22 +0100
commit90ec37cf90035576bcab4d7b36214c9c19a52d24 (patch)
treea05aa9b735ca6c2005dfd1812df33bd416b1d455 /third_party/waf/wafadmin/Tools/compiler_cc.py
parent32cbbed979b931eeb5127629248a94d7e6f3fcfb (diff)
downloadsamba-90ec37cf90035576bcab4d7b36214c9c19a52d24.tar.gz
Move waf into third_party/.
Signed-Off-By: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'third_party/waf/wafadmin/Tools/compiler_cc.py')
-rw-r--r--third_party/waf/wafadmin/Tools/compiler_cc.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/third_party/waf/wafadmin/Tools/compiler_cc.py b/third_party/waf/wafadmin/Tools/compiler_cc.py
new file mode 100644
index 00000000000..642458aba61
--- /dev/null
+++ b/third_party/waf/wafadmin/Tools/compiler_cc.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# Matthias Jahn jahn dôt matthias ât freenet dôt de, 2007 (pmarat)
+
+import os, sys, imp, types, ccroot
+import optparse
+import Utils, Configure, Options
+from Logs import debug
+
+c_compiler = {
+ 'win32': ['msvc', 'gcc'],
+ 'cygwin': ['gcc'],
+ 'darwin': ['gcc'],
+ 'aix': ['xlc', 'gcc'],
+ 'linux': ['gcc', 'icc', 'suncc'],
+ 'sunos': ['gcc', 'suncc'],
+ 'irix': ['gcc'],
+ 'hpux': ['gcc'],
+ 'gnu': ['gcc'],
+ 'default': ['gcc']
+}
+
+def __list_possible_compiler(platform):
+ try:
+ return c_compiler[platform]
+ except KeyError:
+ return c_compiler["default"]
+
+def detect(conf):
+ """
+ for each compiler for the platform, try to configure the compiler
+ in theory the tools should raise a configuration error if the compiler
+ pretends to be something it is not (setting CC=icc and trying to configure gcc)
+ """
+ try: test_for_compiler = Options.options.check_c_compiler
+ except AttributeError: conf.fatal("Add set_options(opt): opt.tool_options('compiler_cc')")
+ orig = conf.env
+ for compiler in test_for_compiler.split():
+ conf.env = orig.copy()
+ try:
+ conf.check_tool(compiler)
+ except Configure.ConfigurationError, e:
+ debug('compiler_cc: %r' % e)
+ else:
+ if conf.env['CC']:
+ orig.table = conf.env.get_merged_dict()
+ conf.env = orig
+ conf.check_message(compiler, '', True)
+ conf.env['COMPILER_CC'] = compiler
+ break
+ conf.check_message(compiler, '', False)
+ break
+ else:
+ conf.fatal('could not configure a c compiler!')
+
+def set_options(opt):
+ build_platform = Utils.unversioned_sys_platform()
+ possible_compiler_list = __list_possible_compiler(build_platform)
+ test_for_compiler = ' '.join(possible_compiler_list)
+ cc_compiler_opts = opt.add_option_group("C Compiler Options")
+ cc_compiler_opts.add_option('--check-c-compiler', default="%s" % test_for_compiler,
+ help='On this platform (%s) the following C-Compiler will be checked by default: "%s"' % (build_platform, test_for_compiler),
+ dest="check_c_compiler")
+
+ for c_compiler in test_for_compiler.split():
+ opt.tool_options('%s' % c_compiler, option_group=cc_compiler_opts)