ilo: construct 3DSTATE_SF in create_rasterizer_state()
[mesa.git] / scons / gallium.py
index 8fc17b3fa4a0e354803e0e0d1c7b7b5fcca44522..2e341e99f83176ea27d18180088340bdbeb54c85 100755 (executable)
@@ -152,7 +152,7 @@ def generate(env):
     platform = env['platform']
     x86 = env['machine'] == 'x86'
     ppc = env['machine'] == 'ppc'
-    gcc = env['gcc']
+    gcc_compat = env['gcc'] or env['clang']
     msvc = env['msvc']
     suncc = env['suncc']
     icc = env['icc']
@@ -251,7 +251,7 @@ def generate(env):
             '_SVID_SOURCE',
             '_BSD_SOURCE',
             '_GNU_SOURCE',
-            'PTHREADS',
+            'HAVE_PTHREAD',
             'HAVE_POSIX_MEMALIGN',
         ]
         if env['platform'] == 'darwin':
@@ -279,7 +279,7 @@ def generate(env):
             ('_WIN32_WINNT', '0x0601'),
             ('WINVER', '0x0601'),
         ]
-        if gcc:
+        if gcc_compat:
             cppdefines += [('__MSVCRT_VERSION__', '0x0700')]
         if msvc:
             cppdefines += [
@@ -289,6 +289,7 @@ def generate(env):
                 '_CRT_SECURE_NO_DEPRECATE',
                 '_SCL_SECURE_NO_WARNINGS',
                 '_SCL_SECURE_NO_DEPRECATE',
+                '_ALLOW_KEYWORD_MACROS',
             ]
         if env['build'] in ('debug', 'checked'):
             cppdefines += ['_DEBUG']
@@ -308,19 +309,20 @@ def generate(env):
     cflags = [] # C
     cxxflags = [] # C++
     ccflags = [] # C & C++
-    if gcc:
+    if gcc_compat:
         ccversion = env['CCVERSION']
         if env['build'] == 'debug':
             ccflags += ['-O0']
-        elif ccversion.startswith('4.2.'):
+        elif env['gcc'] and ccversion.startswith('4.2.'):
             # gcc 4.2.x optimizer is broken
             print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
             ccflags += ['-O0']
         else:
             ccflags += ['-O3']
-        # gcc's builtin memcmp is slower than glibc's
-        # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
-        ccflags += ['-fno-builtin-memcmp']
+        if env['gcc']:
+            # gcc's builtin memcmp is slower than glibc's
+            # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
+            ccflags += ['-fno-builtin-memcmp']
         # Work around aliasing bugs - developers should comment this out
         ccflags += ['-fno-strict-aliasing']
         ccflags += ['-g']
@@ -328,8 +330,9 @@ def generate(env):
             # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
             ccflags += [
                 '-fno-omit-frame-pointer',
-                '-fno-optimize-sibling-calls',
             ]
+            if env['gcc']:
+                ccflags += ['-fno-optimize-sibling-calls']
         if env['machine'] == 'x86':
             ccflags += [
                 '-m32',
@@ -361,14 +364,13 @@ def generate(env):
                 ccflags += [
                     '-mstackrealign', # ensure stack is aligned
                     '-march=i586', # Haiku target is Pentium
-                    '-mtune=i686', # use i686 where we can
-                    '-mmmx' # use mmx math where we can
+                    '-mtune=i686' # use i686 where we can
                 ]
         if env['machine'] == 'x86_64':
             ccflags += ['-m64']
             if platform == 'darwin':
                 ccflags += ['-fno-common']
-        if env['platform'] not in ('windows', 'haiku'):
+        if env['platform'] not in ('cygwin', 'haiku', 'windows'):
             ccflags += ['-fvisibility=hidden']
         # See also:
         # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
@@ -400,9 +402,10 @@ def generate(env):
             ccflags += [
               '/Od', # disable optimizations
               '/Oi', # enable intrinsic functions
-              '/Oy-', # disable frame pointer omission
             ]
         else:
+            if 'MSVC_VERSION' in env and distutils.version.LooseVersion(env['MSVC_VERSION']) < distutils.version.LooseVersion('11.0'):
+                print 'scons: warning: Visual Studio versions prior to 2012 are known to produce incorrect code when optimizations are enabled ( https://bugs.freedesktop.org/show_bug.cgi?id=58718 )'
             ccflags += [
                 '/O2', # optimize for speed
             ]
@@ -412,6 +415,7 @@ def generate(env):
             ]
         else:
             ccflags += [
+                '/Oy-', # disable frame pointer omission
                 '/GL-', # disable whole program optimization
             ]
         ccflags += [
@@ -446,7 +450,7 @@ def generate(env):
             env.Append(SHCCFLAGS = ['/LD'])
     
     # Assembler options
-    if gcc:
+    if gcc_compat:
         if env['machine'] == 'x86':
             env.Append(ASFLAGS = ['-m32'])
         if env['machine'] == 'x86_64':
@@ -455,7 +459,7 @@ def generate(env):
     # Linker options
     linkflags = []
     shlinkflags = []
-    if gcc:
+    if gcc_compat:
         if env['machine'] == 'x86':
             linkflags += ['-m32']
         if env['machine'] == 'x86_64':
@@ -493,13 +497,15 @@ def generate(env):
     env.Append(SHLINKFLAGS = shlinkflags)
 
     # We have C++ in several libraries, so always link with the C++ compiler
-    if env['gcc'] or env['clang']:
+    if gcc_compat:
         env['LINK'] = env['CXX']
 
     # Default libs
     libs = []
-    if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
+    if env['platform'] in ('darwin', 'freebsd', 'linux', 'posix', 'sunos'):
         libs += ['m', 'pthread', 'dl']
+    if env['platform'] in ('linux',):
+        libs += ['rt']
     env.Append(LIBS = libs)
 
     # OpenMP
@@ -529,7 +535,6 @@ def generate(env):
     env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
     env.PkgCheckModules('DRM', ['libdrm >= 2.4.24'])
     env.PkgCheckModules('DRM_INTEL', ['libdrm_intel >= 2.4.30'])
-    env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon >= 2.4.31'])
     env.PkgCheckModules('XORG', ['xorg-server >= 1.6.0'])
     env.PkgCheckModules('KMS', ['libkms >= 2.4.24'])
     env.PkgCheckModules('UDEV', ['libudev > 150'])