SConstruct revision 594fa132b76b87cbb0832cd856a6999b547b1822
11da651f0d6c0041c8e7d52070e887dfe4063d307Logan ChienCOMMON_CFLAGS = ['-Wall', '-Werror']
21da651f0d6c0041c8e7d52070e887dfe4063d307Logan ChienCOMMON_CXXFLAGS = ['-Wall', '-Werror']
31da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien
41da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chienbuild_configurations = {
51da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien    'debug': {
61da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien        'CFLAGS': COMMON_CFLAGS + ['-g'],
71da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien        'CXXFLAGS': COMMON_CXXFLAGS + ['-g']
81da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien    },
91da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien
101da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien    'release': {
111da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien        'CFLAGS': COMMON_CFLAGS + ['-O2'],
121da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien        'CXXFLAGS': COMMON_CXXFLAGS + ['-O2', '-fno-exceptions']
131da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien        # FIXME: We should move -fno-exceptions to COMMON_CXXFLAGS.
141da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien    },
151da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien}
161da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien
17594fa132b76b87cbb0832cd856a6999b547b1822Logan Chientoolkits = {
18594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien    'gcc': {
19594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien        'CC': 'gcc',
20594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien        'CXX': 'g++',
21594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien    },
22594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien
23594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien    'clang': {
24594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien        'CC': 'clang',
25594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien        'CXX': 'clang++',
26594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien    },
27594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien}
28594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien
291da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chienmode = ARGUMENTS.get('mode', 'release')
30594fa132b76b87cbb0832cd856a6999b547b1822Logan Chientoolkit = ARGUMENTS.get('toolkit', 'gcc')
311da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien
321da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chienif not mode in build_configurations:
331da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien    print 'ERROR: Unknown building mode:', mode
3409407ada940687ab3675641e3313f632a2c37be0TDYa    Exit(1)
3509407ada940687ab3675641e3313f632a2c37be0TDYa
361da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chienbuild_config = build_configurations[mode]
37594fa132b76b87cbb0832cd856a6999b547b1822Logan Chienbuild_toolkit = toolkits[toolkit]
3809407ada940687ab3675641e3313f632a2c37be0TDYa
391da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chienprint '===> BUILDING IN ' + mode.upper() + ' MODE ...'
4009407ada940687ab3675641e3313f632a2c37be0TDYa
41594fa132b76b87cbb0832cd856a6999b547b1822Logan Chienimport os
42594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien
43594fa132b76b87cbb0832cd856a6999b547b1822Logan Chienenv = Environment(CC=build_toolkit['CC'],
44594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien                  CXX=build_toolkit['CXX'],
45594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien                  CFLAGS=build_config['CFLAGS'],
461da651f0d6c0041c8e7d52070e887dfe4063d307Logan Chien                  CXXFLAGS=build_config['CXXFLAGS'],
47594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien                  CPPPATH=['utils'],
48594fa132b76b87cbb0832cd856a6999b547b1822Logan Chien                  ENV = {'PATH' : os.environ['PATH']})
49b10ad5844867c7a33bb0d994e3ba55c17e41d18dLogan Chien
50b10ad5844867c7a33bb0d994e3ba55c17e41d18dLogan Chienenv.Program('elfreader',
5188f7f15ef740a4925b17d5ab65c43b4b67fc82e0Logan Chien            source=['ELFHeader.cpp',
5261dfca9e892597db79889addb7a3abf54cd50588Logan Chien                    'ELFSectionHeader.cpp',
5388f7f15ef740a4925b17d5ab65c43b4b67fc82e0Logan Chien                    'ELFTypes.cpp',
54b10ad5844867c7a33bb0d994e3ba55c17e41d18dLogan Chien                    'main.cpp',
55b10ad5844867c7a33bb0d994e3ba55c17e41d18dLogan Chien                    'utils/helper.cpp',
56b10ad5844867c7a33bb0d994e3ba55c17e41d18dLogan Chien                    'utils/term.cpp'])
57