-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSConstruct
More file actions
94 lines (79 loc) · 3.77 KB
/
Copy pathSConstruct
File metadata and controls
94 lines (79 loc) · 3.77 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from SCons.Defaults import processDefines
def config_h_build(target, source, env):
config_h_defines = { }
for define in processDefines(env["CPPDEFINES"]):
l = define.split("=", 1)
if len(l) == 2:
config_h_defines[l[0]] = l[1]
else:
config_h_defines[l[0]] = ""
#print config_h_defines
for a_target, a_source in zip(target, source):
with open(str(a_target), "w") as config_h:
with open(str(a_source), "r") as f:
for line in f:
if line.startswith("#cmakedefine "):
_, key = line.split(None, 1)
key = key.strip()
if key in config_h_defines:
config_h.write("#define %s %s\n" % (key, config_h_defines[key]))
else:
config_h.write("#undef %s\n" % key)
else:
config_h.write("%s" % line)
#env = Environment(CCFLAGS = '-g -O0 -Wall')
env = Environment(CCFLAGS = '-g -O2 -Wall')
#env['CPPDEFINES'] = ['EVHTP_DEBUG=1']
#env['CPPFLAGS'] =
#env['CPPPATH'] = []
#env['LIBPATH'] = []
#env['LIBS'] = []
env['EVHTP_DIR'] = 'libevhtp'
libs = ['pthread', 'rt']
if not env.GetOption('clean'):
conf = Configure(env)
if not conf.CheckLibWithHeader('event', 'event2/event.h', 'c'):
print 'libevent 2.12+ required!'
Exit(1)
if not conf.CheckHeader('sys/un.h'):
conf.env.Append(CPPDEFINES = "NO_SYS_UN")
if not conf.CheckHeader('sys/queue.h'):
env.Command('$EVHTP_DIR/compat/sys/queue.h', '$EVHTP_DIR/compat/sys/queue.h.in', 'cp $SOURCES $TARGET')
if not conf.CheckHeader('sys/tree.h'):
env.Command('$EVHTP_DIR/compat/sys/tree.h', '$EVHTP_DIR/compat/sys/tree.h.in', 'cp $SOURCES $TARGET')
if not conf.CheckFunc('strndup'):
conf.env.Append(CPPDEFINES = ['NO_STRNDUP'])
if not conf.CheckFunc('strnlen'):
conf.env.Append(CPPDEFINES = ['NO_STRNLEN'])
if conf.CheckHeader('openssl/evp.h') and conf.CheckHeader('openssl/kdf.h'):
conf.env.Append(CPPDEFINES = ['USE_CRYPTO_OPENSSL', 'ENABLE_SS'])
if conf.CheckFunc('strerror_r'):
conf.env.Append(CPPDEFINES = ['HAVE_STRERROR_R'])
if conf.CheckFunc('splice'):
conf.env.Append(CPPDEFINES = ['HAVE_SPLICE'])
if not conf.CheckLib('event_openssl'):
conf.env.Append(CPPDEFINES = ['EVHTP_DISABLE_SSL'])
libs += ['event', 'crypto']
else:
libs += ['event', 'event_openssl', 'ssl', 'crypto', 'dl']
conf.env.Append(CPPDEFINES = {"EVHTP_SYS_ARCH" : (8 * conf.CheckTypeSize("size_t"))})
conf.env.Append(CPPDEFINES = ['EVHTP_DISABLE_REGEX', 'EVHTP_DISABLE_EVTHR'])
env = conf.Finish()
if env['PLATFORM'] in ('win32', 'mingw'):
env['LIBS'] += "ws2_32"
env.Decider('timestamp-match')
config_h_action = Action(config_h_build, varlist=['CPPDEFINES'])
env.Command('$EVHTP_DIR/evhtp-config.h', '$EVHTP_DIR/evhtp-config.h.in', config_h_action)
env.Append(CPPPATH = ['libevhtp', 'libevhtp/compat'])
libevhtp_srcs = Split('libevhtp/evhtp.c libevhtp/evhtp_numtoa.c libevhtp/evthr.c libevhtp/htparse.c')
libevhtp_objs = [env.Object(i) for i in libevhtp_srcs]
env.Program('evhtp_get', ['evhtp_get.c', ] + libevhtp_objs,
LIBS = libs,
LIBPATH = ['/usr/local/lib', '/usr/lib', ])
mproxy = env.Program('mproxy', Split('evhtp_proxy.c evhtp_sock_relay.c lru.c dns_forward.c connector.c http_connector.c ss_connector.c encrypt.c utils.c log.c parse_forward_param.c') + libevhtp_objs,
CCFLAGS = env['CCFLAGS'] + ' ',
LIBS = libs,
LIBPATH = ['/usr/local/lib', '/usr/lib', ])
env.Install('/usr/local/bin', mproxy)
env.Alias('install', '/usr/local/bin')
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4