-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
75 lines (64 loc) · 3.02 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
import os
import sys
import subprocess
env = Environment(ENV = os.environ)
env['HAVE_POSIX_BARRIER'] = True
env.Append(CPPPATH = ['/usr/local/include', '/opt/local/include'])
env.Append(LIBPATH = ['/opt/local/lib'])
env.Append(CCFLAGS = '-std=c++0x -D_GNU_SOURCE') # -D__STDC_FORMAT_MACROS')
if sys.platform == 'darwin':
env['CC'] = 'clang'
env['CXX'] = 'clang++'
conf = env.Configure(config_h = "config.h")
conf.Define("__STDC_FORMAT_MACROS")
if not conf.CheckCXX():
print("A compiler with C++11 support is required.")
Exit(1)
print("Checking for gengetopt...", end=' ')
if env.Execute("@which gengetopt &> /dev/null"):
print("not found (required)")
Exit(1)
else: print("found")
if not conf.CheckLibWithHeader("event", "event2/event.h", "C++"):
print("libevent required")
Exit(1)
conf.CheckDeclaration("EVENT_BASE_FLAG_PRECISE_TIMER", '#include <event2/event.h>', "C++")
if not conf.CheckLibWithHeader("pthread", "pthread.h", "C++"):
print("pthread required")
Exit(1)
conf.CheckLib("rt", "clock_gettime", language="C++")
conf.CheckLibWithHeader("zmq", ["algorithm", "zmq.hpp"], "C++")
# conf.CheckFunc('clock_gettime')
if not conf.CheckFunc('pthread_barrier_init'):
conf.env['HAVE_POSIX_BARRIER'] = False
env = conf.Finish()
env.Append(CFLAGS = ' -O3 -Wall -g')
env.Append(CPPFLAGS = ' -O3 -Wall -g')
#env.Append(CPPFLAGS = ' -D_GNU_SOURCE -D__STDC_FORMAT_MACROS')
#env.Append(CPPFLAGS = ' -DUSE_ADAPTIVE_SAMPLER')
#env.Append(CPPFLAGS = ' -DUSE_CUSTOM_PROTOCOL')
env.Command(['cmdline.cc', 'cmdline.h'], 'cmdline.ggo', 'gengetopt < $SOURCE')
src = Split("""mutilate.cc cmdline.cc log.cc distributions.cc util.cc
TCPConnection.cc Generator.cc common.cc""")
if not env['HAVE_POSIX_BARRIER']: # USE_POSIX_BARRIER:
src += ['barrier.cc']
env.Program(target='mutilate', source=src)
env.Program(target='gtest', source=['TestGenerator.cc', 'log.cc', 'util.cc',
'Generator.cc'])
env.Program(target='mutilateudp', source=Split('''mutilateudp.cc cmdline.cc
log.cc Generator.cc distributions.cc util.cc common.cc UDPConnection.cc'''))
if 'DPDK' in os.environ or env.GetOption('clean'):
# NOTE: I am relying on pkg-config and DPDK being installed correctly
dpdk_linker_flags = subprocess.check_output('pkg-config --libs libdpdk', shell=True, text=True).strip()
dpdk_compile_flags = subprocess.check_output('pkg-config --cflags libdpdk', shell=True, text=True).strip()
env_dpdk = Environment()
env_dpdk['DPDK'] = os.environ.get('DPDK', '')
env_dpdk['CPPFLAGS'] = '-I$DPDK/include -O2 -Wall -fno-strict-aliasing ' + dpdk_compile_flags
env_dpdk['CXXFLAGS'] = '-std=c++0x'
env_dpdk['LIBPATH'] = '$DPDK/lib'
env_dpdk['LIBS'] = ['zmq', 'pthread', 'dl']
env_dpdk['_LIBFLAGS'] += ' ' + dpdk_linker_flags
src = Split("""mutilatedpdk.cc DPDKConnection.cc dpdktcp.c""")
obj = list(map(env.Object, Split('''cmdline.cc log.cc Generator.cc distributions.cc util.cc common.cc''')))
env_dpdk.Program(target='mutilatedpdk', source=src+obj)