import os

GMOCK_DIR="~/workspace/cpp/googletest/googlemock"
GTEST_DIR="~/workspace/cpp/googletest/googletest"


LIB_PATH = ['/usr/lib', '/usr/local/lib', '/usr/local/opt/openssl/lib', './lib', './bin','/usr/lib/x86_64-linux-gnu']

env = Environment()
env.Append(CPPPATH=["/usr/local/include", "/usr/include/jsoncpp",
    GMOCK_DIR + "/include",
    GTEST_DIR + "/include", "./inc", "./src", "./lib", "./com/algorithms"] )
env.Append(CCFLAGS = '-fno-elide-constructors -Wall -g -O1 -static -std=c++20 -DBOOST_LOG_DYN_LINK')
env.Append(LIBPATH=["/usr/local/lib", "./lib/googlemock", "./lib/googlemock/gtest"])

env.ParseConfig("pkg-config --cflags glib-2.0")
env.ParseConfig("pkg-config --libs glib-2.0")

print("CPPPATH=", env['CPPPATH'], ", LIBPATH=", env['LIBPATH'])

basictest=env.Program(target='./bin/basic_test', source=['./test/function_ptr_test.cpp'])

tinydiagram=env.Program(target='./bin/tiny_diagram', source=['./exam/tiny_diagram.cpp'])


algotest=env.Program(target='./bin/alogtest', 
    source=['./com/algorithms/wf_sort.cpp', './com/algorithms/AlgoTest.cpp'], 
    LIBS = ['gmock','gtest', 'jsoncpp', 'pthread', 'boost_log', 'boost_timer', 'boost_system', 'boost_chrono'], LIBPATH = LIB_PATH)

unittest=env.Program(target='./bin/unittest', source=['./test/unittest.cpp',
	'./test/basictest.cpp',
    './test/functortest.cpp',
	'./test/stltest.cpp',
    './test/StringUtilTest.cpp',
    './test/jsoncpp_test.cpp',
    './test/RegexTest.cpp',
    './src/TestCase.cpp',
    './src/StringUtil.cpp',
    './test/TestSuiteLoaderTest.cpp',
    './test/HuffmanCodeTest.cpp',
    './test/TimeFuncTest.cpp',
    './test/future_test.cpp',
	'./test/smart_ptr_test.cpp',
    './test/glib_test.cpp'],
    LIBPATH = LIB_PATH,
    LIBS = ['gmock','gtest', 'jsoncpp', 'pthread', 'glib-2.0'])


wordbankdemo=env.Program(target='./bin/wordbankdemo', 
    source=['./exam/WordBankDemo.cpp', './src/WordBank.cpp'],
	CCFLAGS='-fno-elide-constructors -Wall -g -O1 -static -std=c++17 -DBOOST_LOG_DYN_LINK',
    #LINKFLAGS='-pg',
    LIBS = ['boost_log','boost_timer'], 
    LIBPATH = LIB_PATH )    

text2image=env.Program(target='./bin/text2image', source=['./src/text2image.cpp'], 
	LINKFLAGS='-lgd -lpng -lz -ljpeg -lfreetype -lm')

run_example=env.Program(target='./bin/run_example', source=[
    './exam/run_example.cpp',
    './exam/boost_function.cpp',
    './exam/boost_memory.cpp',
    './exam/std_function_exam.cpp',
    './exam/cpp11_lambda.cpp',
    './src/AudioLevelCalculator.cpp'], 
    LIBS = ['jsoncpp', 'pthread','boost_log','boost_thread', 'boost_program_options'], 
    LIBPATH = LIB_PATH)

waltertest=env.Program(target='./bin/waltertest', 
    source=['./test/waltertest.cpp', 
        './src/showbytes.cpp', './src/FileUtil.cpp',
        './src/StringUtil.cpp', './src/MediaUtil.cpp',
        './src/NetworkUtil.cpp'],
    LINKFLAGS='-lm')

#, LIBS = ['gmock', 'gtest'], LIBPATH = ['./bin', GMOCK_DIR + "/lib/.libs", GTEST_DIR + "/lib/.libs" ])
#Default(basic_test)
Default(waltertest,     
   algotest,
    basictest, 
    unittest,
    run_example,
    wordbankdemo)

