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

builder.SetBuildFolder('libz')

rvalue = {}
for cxx in builder.targets:
  binary = Extension.StaticLibrary(builder, cxx, 'z')
  binary.compiler.includes += [
    os.path.join(builder.sourcePath, 'zlib'),
  ]

  if binary.compiler.target.platform in ['linux', 'mac']:
    binary.compiler.defines += ['HAVE_UNISTD_H']

  if binary.compiler.family == 'clang':
    # https://llvm.org/bugs/show_bug.cgi?id=16428
    binary.compiler.cflags += ['-Wno-attributes', '-Wno-deprecated-non-prototype']

  # Defined as ZLIB_SRCS in zlib/CMakeLists.txt
  binary.sources += [
    'adler32.c',
    'compress.c',
    'crc32.c',
    'deflate.c',
    'gzclose.c',
    'gzlib.c',
    'gzread.c',
    'gzwrite.c',
    'infback.c',
    'inffast.c',
    'inflate.c',
    'inftrees.c',
    'trees.c',
    'uncompr.c',
    'zutil.c',
  ]

  rvalue[binary.compiler.target.arch] = builder.Add(binary)
