import glob
import sys
import os.path

env = Environment(CCFLAGS = '-ggdb3 -Wall -m32 -std=gnu++1y -O3 -Wno-write-strings',
    LINKFLAGS = '-ggdb3 -Wall -m32 -std=gnu++1y -O3' )
#env = Environment(CCFLAGS = '-ggdb3 -Wall -m32 -pg -std=gnu++1z -fprofile-arcs -ftest-coverage -Wno-write-strings',
#                  LINKFLAGS = '-ggdb3 -Wall -m32 -pg -std=gnu++1z -fprofile-arcs -ftest-coverage -Wno-write-strings' )

if os.path.exists('/usr/bin/g++-7'):
	env.Replace(CXX = 'g++-7')

if os.path.exists('/usr/bin/g++-9'):
	env.Replace(CXX = 'g++-9')
	env.Replace(CCFLAGS = '-ggdb3 -Wall -m32 -std=gnu++17 -O3 -Wno-write-strings')
	env.Replace(LINKFLAGS = '-ggdb3 -Wall -m32 -std=gnu++17 -O3')

if os.path.exists('/usr/bin/g++-10'):
       env.Replace(CXX = 'g++-10')
       env.Replace(CCFLAGS = '-ggdb3 -Wall -m32 -std=gnu++17 -O3 -Wno-write-strings')
       env.Replace(LINKFLAGS = '-ggdb3 -Wall -m32 -std=gnu++17 -O3')

base_src = glob.glob('[a-l]*.cpp') + glob.glob('[n-z]*.cpp') + glob.glob('mo*.cpp') + ['magic.cpp','memory.cpp','meta.cpp','MobActivity.cpp','Leaderboard.cpp','DC.cpp']
wizard_src = glob.glob('wizard/*.cpp')
class_src = glob.glob('class/*.cpp')
backend_src = glob.glob('Backend/*.cpp')

env.Program('dcastle.debug', ['main.cpp'],
CPPPATH = ['include'], CPPDEFINES=['LINUX'],
LIBS=['dcastle', 'crypt', 'mcheck', 'z', 'pq', 'XmlRpc', 'twitcurl'], LIBPATH=['.','/usr/local/lib']);

env.Program('showplayer', ['../scripts/showplayerxp.cpp'],
CPPPATH = ['include'], CPPDEFINES=['LINUX'],
LIBS=['dcastle', 'crypt', 'mcheck', 'z', 'pq', 'XmlRpc', 'twitcurl'], LIBPATH=['.','/usr/local/lib']);

env.StaticLibrary('dcastle', [base_src,wizard_src,class_src,backend_src],
CPPPATH = ['include','/usr/include/pgsql/'], CPPDEFINES=['LINUX', 'TWITTER'],
LIBS=[], LIBPATH=['/usr/local/lib']);

