import os
import sys
import glob

env = Environment(ENV=os.environ)
# conf = Configure(env)
# print conf.CheckLib('yaml-cpp')

# profiling (uh, i think, it's been a while): '-pg', '-g',
# increase compile time verbosity (e.g. figure out include paths): , '--verbose'
# increase link time verbosity (e.g. figure out lib paths):, '-Wl,--verbose'
env.Append(CPPFLAGS =  ['-Ofast', '-std=c++11', '-Wall', '-Wextra', '-pedantic'])
env.Append(LINKFLAGS = ['-Ofast', '-std=c++11'])
env.Append(CPPPATH = ['../include'])
env.Append(CPPDEFINES={'STATE_MAX':'500', 'SIZE_MAX':'\(\(size_t\)-1\)', 'PI':'3.1415926535897932', 'EPS':'1e-6'})  # maybe reduce the state max to something reasonable?

binary_names = ['bcrham', 'hample']

sources = []
for fname in glob.glob(os.getenv('PWD') + '/src/*.cc'):
    is_binary = False
    for bname in binary_names:
        if bname in fname:
            is_binary = True
            break
    if not is_binary:
        # sources.append(fname.replace('src/', '_build/'))
        sources.append(fname)  # seems to work fine this was as well for me, and in this issue someone had it break with the previous line https://github.com/psathyrella/ham/issues/16

env.Library(target='ham', source=sources)

for bname in binary_names:
    env.Program(target='../' + bname, source=bname + '.cc', LIBS=['ham', 'yaml-cpp', 'gsl', 'gslcblas'], LIBPATH=['.'])
