forked from zaphoyd/websocketpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
136 lines (111 loc) · 4.58 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#AddOption('--prefix',
# dest='prefix',
# nargs=1, type='string',
# action='store',
# metavar='DIR',
# help='installation prefix')
#env = Environment(PREFIX = GetOption('prefix'))
import os, sys
env = Environment(ENV = os.environ)
## Boost
##
## Note: You need to either set BOOSTROOT to the root of a stock Boost distribution
## or set BOOST_INCLUDES and BOOST_LIBS if Boost comes with your OS distro e.g. and
## needs BOOST_INCLUDES=/usr/include/boost and BOOST_LIBS=/usr/lib like Ubuntu.
##
if os.environ.has_key('BOOSTROOT'):
env['BOOST_INCLUDES'] = os.environ['BOOSTROOT']
env['BOOST_LIBS'] = os.path.join(os.environ['BOOSTROOT'], 'stage', 'lib')
elif os.environ.has_key('BOOST_INCLUDES') and os.environ.has_key('BOOST_LIBS'):
env['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES']
env['BOOST_LIBS'] = os.environ['BOOST_LIBS']
else:
raise SCons.Errors.UserError, "Neither BOOSTROOT, nor BOOST_INCLUDES + BOOST_LIBS was set!"
env.Append(CPPPATH = [env['BOOST_INCLUDES']])
env.Append(LIBPATH = [env['BOOST_LIBS']])
boost_linkshared = False
def boostlibs(libnames):
if env['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
# http://www.boost.org/doc/libs/1_49_0/more/getting_started/windows.html#auto-linking
return []
else:
libs = []
prefix = env['SHLIBPREFIX'] if boost_linkshared else env['LIBPREFIX']
suffix = env['SHLIBSUFFIX'] if boost_linkshared else env['LIBSUFFIX']
for name in libnames:
lib = File(os.path.join(env['BOOST_LIBS'], '%sboost_%s%s' % (prefix, name, suffix)))
libs.append(lib)
return libs
if env['PLATFORM'].startswith('win'):
env.Append(CPPDEFINES = ['WIN32',
'NDEBUG',
'WIN32_LEAN_AND_MEAN',
'_WIN32_WINNT=0x0600',
'_CONSOLE',
'_WEBSOCKETPP_CPP11_FRIEND_'])
arch_flags = '/arch:SSE2'
opt_flags = '/Ox /Oi /fp:fast'
warn_flags = '/W3 /wd4996 /wd4995 /wd4355'
env['CCFLAGS'] = '%s /EHsc /GR /GS- /MD /nologo %s %s' % (warn_flags, arch_flags, opt_flags)
env['LINKFLAGS'] = '/INCREMENTAL:NO /MANIFEST /NOLOGO /OPT:REF /OPT:ICF /MACHINE:X86'
elif env['PLATFORM'] == 'posix':
env.Append(CPPDEFINES = ['NDEBUG'])
env.Append(CCFLAGS = ['-Wall', '-fno-strict-aliasing'])
env.Append(CCFLAGS = ['-O3', '-fomit-frame-pointer', '-march=core2'])
#env['LINKFLAGS'] = ''
if env['PLATFORM'].startswith('win'):
env['LIBPATH'] = env['BOOST_LIBS']
else:
env['LIBPATH'] = ['/usr/lib',
'/usr/local/lib',
env['BOOST_LIBS']]
platform_libs = []
tls_libs = []
tls_build = False
if env['PLATFORM'] == 'posix':
platform_libs = ['pthread', 'rt']
tls_libs = ['ssl', 'crypto']
tls_build = True
elif env['PLATFORM'] == 'darwin':
tls_libs = ['ssl', 'crypto']
tls_build = True
elif env['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
pass
releasedir = 'build/release/'
debugdir = 'build/debug/'
builddir = releasedir
Export('env')
Export('platform_libs')
Export('boostlibs')
Export('tls_libs')
## END OF CONFIG !!
## TARGETS:
static_lib, shared_lib = SConscript('src/SConscript',
variant_dir = builddir + 'websocketpp',
duplicate = 0)
wslib = static_lib
Export('wslib')
wsperf = SConscript('#/examples/wsperf/SConscript',
variant_dir = builddir + 'wsperf',
duplicate = 0)
echo_server = SConscript('#/examples/echo_server/SConscript',
variant_dir = builddir + 'echo_server',
duplicate = 0)
if tls_build:
echo_server_tls = SConscript('#/examples/echo_server_tls/SConscript',
variant_dir = builddir + 'echo_server_tls',
duplicate = 0)
echo_client = SConscript('#/examples/echo_client/SConscript',
variant_dir = builddir + 'echo_client',
duplicate = 0)
chat_client = SConscript('#/examples/chat_client/SConscript',
variant_dir = builddir + 'chat_client',
duplicate = 0)
chat_server = SConscript('#/examples/chat_server/SConscript',
variant_dir = builddir + 'chat_server',
duplicate = 0)
concurrent_server = SConscript('#/examples/concurrent_server/SConscript',
variant_dir = builddir + 'concurrent_server',
duplicate = 0)