import sys
import os

Import('env')

tests_env = env.Clone()

libs = [
    "corelog",
    "log",
    "stdc++",
]

if sys.platform != "darwin":
    libs += ['rt', 'pthread']

if sys.platform == "freebsd":
    libs += ['execinfo']

if sys.platform == "linux2":
    libs += ['uuid', 'resolv']


tests_env.Append(LIBS = libs)

td = []

# Tests
tests = [ ]
for f in Glob('#tests/*_test.cc'):
    tests.append(os.path.basename(f.rstr()[0:-3]))

for t in tests:
    td += tests_env.Program(t, t+".cc")

AlwaysBuild(Alias('testbench', td, "tests/testbench.py"))


