scons: Add Haiku build support
[mesa.git] / scons / gallium.py
index 8cd3bc7f6e0dd3385c82f5589fefb9b9b89b6f8b..5a0c6fef13c175b0069afa3492ad93980e09a9cf 100755 (executable)
@@ -113,11 +113,6 @@ def generate(env):
 
     # Toolchain
     platform = env['platform']
-    if env['toolchain'] == 'default':
-        if platform == 'winddk':
-            env['toolchain'] = 'winddk'
-        elif platform == 'wince':
-            env['toolchain'] = 'wcesdk'
     env.Tool(env['toolchain'])
 
     # Allow override compiler and specify additional flags from environment
@@ -279,7 +274,9 @@ def generate(env):
             ('_WIN32_WINNT', '0x0601'),
             ('WINVER', '0x0601'),
         ]
-        if msvc and env['toolchain'] != 'winddk':
+        if gcc:
+            cppdefines += [('__MSVCRT_VERSION__', '0x0700')]
+        if msvc:
             cppdefines += [
                 'VC_EXTRALEAN',
                 '_USE_MATH_DEFINES',
@@ -290,57 +287,10 @@ def generate(env):
             ]
         if env['build'] in ('debug', 'checked'):
             cppdefines += ['_DEBUG']
-    if env['toolchain'] == 'winddk':
-        # Mimic WINDDK's builtin flags. See also:
-        # - WINDDK's bin/makefile.new i386mk.inc for more info.
-        # - buildchk_wxp_x86.log files, generated by the WINDDK's build
-        # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
-        if machine == 'x86':
-            cppdefines += ['_X86_', 'i386']
-        if machine == 'x86_64':
-            cppdefines += ['_AMD64_', 'AMD64']
-    if platform == 'winddk':
-        cppdefines += [
-            'STD_CALL',
-            ('CONDITION_HANDLING', '1'),
-            ('NT_INST', '0'),
-            ('WIN32', '100'),
-            ('_NT1X_', '100'),
-            ('WINNT', '1'),
-            ('_WIN32_WINNT', '0x0501'), # minimum required OS version
-            ('WINVER', '0x0501'),
-            ('_WIN32_IE', '0x0603'),
-            ('WIN32_LEAN_AND_MEAN', '1'),
-            ('DEVL', '1'),
-            ('__BUILDMACHINE__', 'WinDDK'),
-            ('FPO', '0'),
-        ]
-        if env['build'] in ('debug', 'checked'):
-            cppdefines += [('DBG', 1)]
-    if platform == 'wince':
-        cppdefines += [
-            '_CRT_SECURE_NO_DEPRECATE',
-            '_USE_32BIT_TIME_T',
-            'UNICODE',
-            '_UNICODE',
-            ('UNDER_CE', '600'),
-            ('_WIN32_WCE', '0x600'),
-            'WINCEOEM',
-            'WINCEINTERNAL',
-            'WIN32',
-            'STRICT',
-            'x86',
-            '_X86_',
-            'INTERNATIONAL',
-            ('INTLMSG_CODEPAGE', '1252'),
-        ]
     if platform == 'windows':
         cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
-    if platform == 'winddk':
-        cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
-    if platform == 'wince':
-        cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
-        cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
+    if platform == 'haiku':
+        cppdefines += ['BEOS_THREADS']
     if env['embedded']:
         cppdefines += ['PIPE_SUBSYSTEM_EMBEDDED']
     env.Append(CPPDEFINES = cppdefines)
@@ -359,9 +309,12 @@ def generate(env):
             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']
         # Work around aliasing bugs - developers should comment this out
         ccflags += ['-fno-strict-aliasing']
-        ccflags += ['-g3']
+        ccflags += ['-g']
         if env['build'] in ('checked', 'profile'):
             # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
             ccflags += [
@@ -448,6 +401,7 @@ def generate(env):
             '/fp:fast', # fast floating point 
             '/W3', # warning level
             #'/Wp64', # enable 64 bit porting warnings
+            '/wd4996', # disable deprecated POSIX name warnings
         ]
         if env['machine'] == 'x86':
             ccflags += [
@@ -457,39 +411,6 @@ def generate(env):
             ccflags += [
                 # TODO
             ]
-        if platform == 'winddk':
-            ccflags += [
-                '/Zl', # omit default library name in .OBJ
-                '/Zp8', # 8bytes struct member alignment
-                '/Gy', # separate functions for linker
-                '/Gm-', # disable minimal rebuild
-                '/WX', # treat warnings as errors
-                '/Gz', # __stdcall Calling convention
-                '/GX-', # disable C++ EH
-                '/GR-', # disable C++ RTTI
-                '/GF', # enable read-only string pooling
-                '/G6', # optimize for PPro, P-II, P-III
-                '/Ze', # enable extensions
-                '/Gi-', # disable incremental compilation
-                '/QIfdiv-', # disable Pentium FDIV fix
-                '/hotpatch', # prepares an image for hotpatching.
-                #'/Z7', #enable old-style debug info
-            ]
-        if platform == 'wince':
-            # See also C:\WINCE600\public\common\oak\misc\makefile.def
-            ccflags += [
-                '/Zl', # omit default library name in .OBJ
-                '/GF', # enable read-only string pooling
-                '/GR-', # disable C++ RTTI
-                '/GS', # enable security checks
-                # Allow disabling language conformance to maintain backward compat
-                #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
-                #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
-                #'/wd4867',
-                #'/wd4430',
-                #'/MT',
-                #'/U_MT',
-            ]
         # Automatic pdb generation
         # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
         env.EnsureSConsVersion(0, 98, 0)
@@ -532,6 +453,14 @@ def generate(env):
             pass
         else:
             env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
+        if env['platform'] == 'windows':
+            # Avoid depending on gcc runtime DLLs
+            linkflags += ['-static-libgcc']
+            if 'w64' in env['CC'].split('-'):
+                linkflags += ['-static-libstdc++']
+            # Handle the @xx symbol munging of DLL exports
+            shlinkflags += ['-Wl,--enable-stdcall-fixup']
+            #shlinkflags += ['-Wl,--kill-at']
     if msvc:
         if env['build'] == 'release':
             # enable Link-time Code Generation
@@ -544,45 +473,6 @@ def generate(env):
             '/fixed:no',
             '/incremental:no',
         ]
-    if platform == 'winddk':
-        linkflags += [
-            '/merge:_PAGE=PAGE',
-            '/merge:_TEXT=.text',
-            '/section:INIT,d',
-            '/opt:ref',
-            '/opt:icf',
-            '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
-            '/incremental:no',
-            '/fullbuild',
-            '/release',
-            '/nodefaultlib',
-            '/wx',
-            '/debug',
-            '/debugtype:cv',
-            '/version:5.1',
-            '/osversion:5.1',
-            '/functionpadmin:5',
-            '/safeseh',
-            '/pdbcompress',
-            '/stack:0x40000,0x1000',
-            '/driver',
-            '/align:0x80',
-            '/subsystem:native,5.01',
-            '/base:0x10000',
-
-            '/entry:DrvEnableDriver',
-        ]
-        if env['build'] != 'release':
-            linkflags += [
-                '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
-            ]
-    if platform == 'wince':
-        linkflags += [
-            '/nodefaultlib',
-            #'/incremental:no',
-            #'/fullbuild',
-            '/entry:_DllMainCRTStartup',
-        ]
     env.Append(LINKFLAGS = linkflags)
     env.Append(SHLINKFLAGS = shlinkflags)
 
@@ -596,6 +486,18 @@ def generate(env):
         libs += ['m', 'pthread', 'dl']
     env.Append(LIBS = libs)
 
+    # OpenMP
+    if env['openmp']:
+        if env['msvc']:
+            env.Append(CCFLAGS = ['/openmp'])
+            # When building openmp release VS2008 link.exe crashes with LNK1103 error.
+            # Workaround: overwrite PDB flags with empty value as it isn't required anyways
+            if env['build'] == 'release':
+                env['PDB'] = ''
+        if env['gcc']:
+            env.Append(CCFLAGS = ['-fopenmp'])
+            env.Append(LIBS = ['gomp'])
+
     # Load tools
     env.Tool('lex')
     env.Tool('yacc')
@@ -607,6 +509,7 @@ def generate(env):
     createInstallMethods(env)
 
     env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
+    env.PkgCheckModules('XCB', ['x11-xcb', 'xcb-glx'])
     env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
     env.PkgCheckModules('DRM', ['libdrm'])
     env.PkgCheckModules('DRM_INTEL', ['libdrm_intel'])