# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: 
import os

for cxx in MMS.all_targets:
  name = 'test_loader'
  binary = MMS.Program(cxx, name)

  # add some required defines for Linux builds
  if binary.compiler.target.platform == 'linux' and binary.compiler.target.arch == 'x86':
    binary.compiler.defines += ['LIB_PREFIX=""', 'LIB_SUFFIX="_i486.so"']

  # add some required defines for Linux builds
  if binary.compiler.target.platform == 'linux' and binary.compiler.target.arch == 'x86_64':
    binary.compiler.defines += ['LIB_PREFIX="lib"', 'LIB_SUFFIX=".so"']

  if binary.compiler.target.platform == 'linux':
    binary.compiler.linkflags += ['-ldl']

  # TODO: something makes it try and compile with /SUBSYSTEM:WINDOWS which then causes it to complain that WinMain is missing
  if binary.compiler.target.platform == 'windows':
    binary.compiler.linkflags = ['kernel32.lib', 'shell32.lib']

  binary.compiler.cxxincludes += [
    os.path.join(builder.sourcePath, 'core'),
    os.path.join(builder.sourcePath, 'core', 'sourcehook'),
    os.path.join(builder.sourcePath, 'loader'),
  ]

  if binary.compiler.version >= 'gcc-4.9':
    binary.compiler.cxxflags += ['-fno-devirtualize']
  if binary.compiler.version >= 'clang-2.9' or binary.compiler.version >= 'apple-clang-3.0':
    binary.compiler.cxxflags += ['-Wno-null-dereference']

  binary.sources += [
    'main.cpp',
    '../gamedll.cpp',
    '../loader.cpp',
    '../serverplugin.cpp',
    '../utility.cpp',
    'determinebackends1.cpp',
    'testutility.cpp',
  ]

  builder.Add(binary)
