# vim: set ts=2 sw=2 tw=99 noet ft=python: 
import os

binary = SM.Program(builder, 'spcomp')
compiler = binary.compiler
compiler.includes += [
  os.path.join(builder.sourcePath, 'public'),
  os.path.join(builder.sourcePath, 'public', 'sourcepawn'),
  os.path.join(builder.sourcePath, 'sourcepawn', 'compiler'),
  os.path.join(builder.buildPath, 'includes'),
]
 
if compiler.cc.behavior == 'gcc':
  compiler.cflags += ['-Wno-format']
  if builder.target_platform == 'linux':
    compiler.postlink += ['-lgcc', '-lm']
elif compiler.cc.behavior == 'msvc':
  compiler.linkflags.remove('/SUBSYSTEM:WINDOWS')
  compiler.linkflags.append('/SUBSYSTEM:CONSOLE')
 
if builder.target_platform == 'linux':
  compiler.defines += [
    'LINUX',
    'HAVE_STDINT_H',
    'AMX_ANSIONLY',
    'ENABLE_BINRELOC',
    '_GNU_SOURCE'
  ]
elif builder.target_platform == 'mac':
  compiler.defines += [
    'DARWIN',
    'HAVE_STDINT_H',
    'AMX_ANSIONLY',
    'ENABLE_BINRELOC',
    'HAVE_SAFESTR'
  ]
 
binary.sources += [
  'libpawnc.c',
  'lstring.c',
  'memfile.c',
  'pawncc.c',
  'sc1.c',
  'sc2.c',
  'sc3.c',
  'sc4.c',
  'sc5.c',
  'sc6.c',
  'sc7.c',
  'scexpand.c',
  'sci18n.c',
  'sclist.c',
  'scmemfil.c',
  'scstate.c',
  'sctracker.c',
  'scvars.c',
  'sp_file.c',
  'zlib/adler32.c',
  'zlib/compress.c',
  'zlib/crc32.c',
  'zlib/deflate.c',
  'zlib/gzio.c',
  'zlib/infback.c',
  'zlib/inffast.c',
  'zlib/inflate.c',
  'zlib/inftrees.c',
  'zlib/trees.c',
  'zlib/uncompr.c',
  'zlib/zutil.c',
  'sp_symhash.c'
]
if builder.target_platform == 'linux':
  binary.sources.append('binreloc.c')
 
SM.spcomp = builder.Add(binary)