import os

# SConstruct for dtl examples

env   = Environment(CPPPATH='..')
debug = ARGUMENTS.get('debug', 'n')
if debug == 'y' or debug == 'yes':
    env.Append(CPPFLAGS = ['-Wall', '-g'])
else:
    env.Append(CPPFLAGS = ['-Wall', '-O2'])

if os.sys.platform != "win32":
    env.Append(CPPDEFINES = ['HAVE_UNISTD_H'])

conf = Configure(env);

if not conf.CheckCXX():
    print "The C++ compiler is not installed!"
    Exit(1)

libs = ['stdc++']
for lib in libs:
    if not conf.CheckLib(lib):
        print "library " + lib + " not installed!"
        Exit(1)

conf.Finish()

targets = { 'strdiff'    : ['strdiff.cpp',    'common.cpp'], # diff between two string sequences
            'intdiff'    : ['intdiff.cpp'],                  # diff between two integer sequences
            'unidiff'    : ['unidiff.cpp',    'common.cpp'], # unified diff between two files
            'unistrdiff' : ['unistrdiff.cpp', 'common.cpp'], # unified diff between two strings
            'bdiff'      : ['bdiff.cpp',      'common.cpp'], # diff between two byte sequences
            'strdiff3'   : ['strdiff3.cpp',   'common.cpp'], # three-way string diff program using dtl
            'intdiff3'   : ['intdiff3.cpp'],                 # three-way integer diff program using dtl
            'patch'      : ['patch.cpp',      'common.cpp'], # string patch program using dtl
            'fpatch'     : ['fpatch.cpp',     'common.cpp'], # file patch program using dtl
            'st2ses'     : ['st2ses.cpp',     'common.cpp'], # convert SES format file to SES instance
            'strdiff_cp' : ['strdiff_cp.cpp', 'common.cpp'], # diff between two string sequences with custom printer
            }

[ env.Program(target, targets[target]) for target in targets ]
