revert Makefile change
[c11concurrency-benchmarks.git] / gdax-orderbook-hpp / demo / dependencies / websocketpp-0.7.0 / SConstruct
1 import os, sys, commands
2 env = Environment(ENV = os.environ)
3
4 # figure out a better way to configure this
5 if os.environ.has_key('CXX'):
6     env['CXX'] = os.environ['CXX']
7
8 if os.environ.has_key('DEBUG'):
9     env['DEBUG'] = os.environ['DEBUG']
10
11 if os.environ.has_key('CXXFLAGS'):
12     #env['CXXFLAGS'] = os.environ['CXXFLAGS']
13     env.Append(CXXFLAGS = os.environ['CXXFLAGS'])
14
15 if os.environ.has_key('LINKFLAGS'):
16     #env['LDFLAGS'] = os.environ['LDFLAGS']
17     env.Append(LINKFLAGS = os.environ['LINKFLAGS'])
18
19 ## Boost
20 ##
21 ## Note: You need to either set BOOSTROOT to the root of a stock Boost distribution
22 ## or set BOOST_INCLUDES and BOOST_LIBS if Boost comes with your OS distro e.g. and
23 ## needs BOOST_INCLUDES=/usr/include/boost and BOOST_LIBS=/usr/lib like Ubuntu.
24 ##
25 if os.environ.has_key('BOOSTROOT'):
26     os.environ['BOOST_ROOT'] = os.environ['BOOSTROOT']
27
28 if os.environ.has_key('BOOST_ROOT'):
29    env['BOOST_INCLUDES'] = os.environ['BOOST_ROOT']
30    env['BOOST_LIBS'] = os.path.join(os.environ['BOOST_ROOT'], 'stage', 'lib')
31 elif os.environ.has_key('BOOST_INCLUDES') and os.environ.has_key('BOOST_LIBS'):
32    env['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES']
33    env['BOOST_LIBS'] = os.environ['BOOST_LIBS']
34 else:
35    raise SCons.Errors.UserError, "Neither BOOST_ROOT, nor BOOST_INCLUDES + BOOST_LIBS was set!"
36
37 ## Custom OpenSSL
38 if os.environ.has_key('OPENSSL_PATH'):
39    env.Append(CPPPATH = os.path.join(os.environ['OPENSSL_PATH'], 'include'))
40    env.Append(LIBPATH = os.environ['OPENSSL_PATH'])
41
42 if os.environ.has_key('WSPP_ENABLE_CPP11'):
43    env['WSPP_ENABLE_CPP11'] = True
44 else:
45    env['WSPP_ENABLE_CPP11'] = False
46
47 boost_linkshared = False
48
49 def boostlibs(libnames,localenv):
50    if localenv['PLATFORM'].startswith('win'):
51       # Win/VC++ supports autolinking. nothing to do.
52       # http://www.boost.org/doc/libs/1_49_0/more/getting_started/windows.html#auto-linking
53       return []
54    else:
55       libs = []
56       prefix = localenv['SHLIBPREFIX'] if boost_linkshared else localenv['LIBPREFIX']
57       suffix = localenv['SHLIBSUFFIX'] if boost_linkshared else localenv['LIBSUFFIX']
58       for name in libnames:
59          lib = File(os.path.join(localenv['BOOST_LIBS'], '%sboost_%s%s' % (prefix, name, suffix)))
60          libs.append(lib)
61       return libs
62
63 if env['PLATFORM'].startswith('win'):
64    env.Append(CPPDEFINES = ['WIN32',
65                             'NDEBUG',
66                             'WIN32_LEAN_AND_MEAN',
67                             '_WIN32_WINNT=0x0600',
68                             '_CONSOLE',
69                             'BOOST_TEST_DYN_LINK',
70                             'NOMINMAX',
71                             '_WEBSOCKETPP_CPP11_MEMORY_',
72                             '_WEBSOCKETPP_CPP11_FUNCTIONAL_'])
73    arch_flags  = '/arch:SSE2'
74    opt_flags   = '/Ox /Oi /fp:fast'
75    warn_flags  = '/W3 /wd4996 /wd4995 /wd4355'
76    env['CCFLAGS'] = '%s /EHsc /GR /GS- /MD /nologo %s %s' % (warn_flags, arch_flags, opt_flags)
77    env['LINKFLAGS'] = '/INCREMENTAL:NO /MANIFEST /NOLOGO /OPT:REF /OPT:ICF /MACHINE:X86'
78 elif env['PLATFORM'] == 'posix':
79    if env.has_key('DEBUG'):
80       env.Append(CCFLAGS = ['-g', '-O0'])
81    else:
82       env.Append(CPPDEFINES = ['NDEBUG'])
83       env.Append(CCFLAGS = ['-O1', '-fomit-frame-pointer'])
84    env.Append(CCFLAGS = ['-Wall'])
85    #env['LINKFLAGS'] = ''
86 elif env['PLATFORM'] == 'darwin':
87    if not os.environ.has_key('CXX'):
88       env['CXX'] = "clang++"
89    if env.has_key('DEBUG'):
90       env.Append(CCFLAGS = ['-g', '-O0'])
91    else:
92       env.Append(CPPDEFINES = ['NDEBUG'])
93       env.Append(CCFLAGS = ['-O1', '-fomit-frame-pointer'])
94    env.Append(CCFLAGS = ['-Wall'])
95    #env['LINKFLAGS'] = ''
96
97 if env['PLATFORM'].startswith('win'):
98    #env['LIBPATH'] = env['BOOST_LIBS']
99    pass
100 else:
101    env.Append(LIBPATH = ['/usr/lib', '/usr/local/lib'])
102
103 # Compiler specific warning flags
104 if env['CXX'].startswith('g++'):
105    #env.Append(CCFLAGS = ['-Wconversion'])
106    env.Append(CCFLAGS = ['-Wcast-align'])
107    env.Append(CCFLAGS = ['-Wshadow'])
108    env.Append(CCFLAGS = ['-Wunused-parameter'])
109 elif env['CXX'].startswith('clang++'):
110    #env.Append(CCFLAGS = ['-Wcast-align'])
111    #env.Append(CCFLAGS = ['-Wglobal-constructors'])
112    #env.Append(CCFLAGS = ['-Wconversion'])
113    env.Append(CCFLAGS = ['-Wno-padded'])
114    env.Append(CCFLAGS = ['-Wshadow'])
115    env.Append(CCFLAGS = ['-Wunused-parameter'])
116
117    env.Append(CCFLAGS = ['-Wsometimes-uninitialized'])
118    env.Append(CCFLAGS = ['-Wuninitialized'])
119
120    #env.Append(CCFLAGS = ['-Weverything'])
121    #env.Append(CCFLAGS = ['-Wno-documentation'])
122    #env.Append(CCFLAGS = ['-Wno-weak-vtables'])
123    #env.Append(CCFLAGS = ['-Wno-global-constructors'])
124    #env.Append(CCFLAGS = ['-Wno-sign-conversion'])
125    #env.Append(CCFLAGS = ['-Wno-exit-time-destructors'])
126
127
128
129
130    # Wpadded
131    # Wsign-conversion
132    #
133
134 platform_libs = []
135 tls_libs = []
136
137 tls_build = False
138
139 if env['PLATFORM'] == 'posix':
140    platform_libs = ['pthread', 'rt']
141    tls_libs = ['ssl', 'crypto']
142    tls_build = True
143 elif env['PLATFORM'] == 'darwin':
144    tls_libs = ['ssl', 'crypto']
145    tls_build = True
146 elif env['PLATFORM'].startswith('win'):
147    # Win/VC++ supports autolinking. nothing to do.
148    pass
149
150 ## Append WebSocket++ path
151 env.Append(CPPPATH = ['#'])
152
153 ##### Set up C++11 environment
154 polyfill_libs = [] # boost libraries used as drop in replacements for incomplete
155                    # C++11 STL implementations
156 env_cpp11 = env.Clone ()
157
158 if env_cpp11['CXX'].startswith('g++'):
159    # TODO: check g++ version
160    GCC_VERSION = commands.getoutput(env_cpp11['CXX'] + ' -dumpversion')
161
162    if GCC_VERSION > "4.4.0":
163       print "C++11 build environment partially enabled"
164       env_cpp11.Append(WSPP_CPP11_ENABLED = "true",CXXFLAGS = ['-std=c++0x'],TOOLSET = ['g++'],CPPDEFINES = ['_WEBSOCKETPP_CPP11_STL_'])
165    else:
166       print "C++11 build environment is not supported on this version of G++"
167 elif env_cpp11['CXX'].startswith('clang++'):
168    print "C++11 build environment enabled"
169    env.Append(CXXFLANGS = ['-stdlib=libc++'],LINKFLAGS=['-stdlib=libc++'])
170    env_cpp11.Append(WSPP_CPP11_ENABLED = "true",CXXFLAGS = ['-std=c++0x','-stdlib=libc++'],LINKFLAGS = ['-stdlib=libc++'],TOOLSET = ['clang++'],CPPDEFINES = ['_WEBSOCKETPP_CPP11_STL_'])
171
172    # look for optional second boostroot compiled with clang's libc++ STL library
173    # this prevents warnings/errors when linking code built with two different
174    # incompatible STL libraries.
175    if os.environ.has_key('BOOST_ROOT_CPP11'):
176       env_cpp11['BOOST_INCLUDES'] = os.environ['BOOST_ROOT_CPP11']
177       env_cpp11['BOOST_LIBS'] = os.path.join(os.environ['BOOST_ROOT_CPP11'], 'stage', 'lib')
178    elif os.environ.has_key('BOOST_INCLUDES_CPP11') and os.environ.has_key('BOOST_LIBS_CPP11'):
179       env_cpp11['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES_CPP11']
180       env_cpp11['BOOST_LIBS'] = os.environ['BOOST_LIBS_CPP11']
181 else:
182    print "C++11 build environment disabled"
183
184 # if the build system is known to allow the isystem modifier for library include
185 # values then use it for the boost libraries. Otherwise just add them to the
186 # regular CPPPATH values.
187 if env['CXX'].startswith('g++') or env['CXX'].startswith('clang'):
188     env.Append(CPPFLAGS = '-isystem ' + env['BOOST_INCLUDES'])
189 else:
190     env.Append(CPPPATH = [env['BOOST_INCLUDES']])
191 env.Append(LIBPATH = [env['BOOST_LIBS']])
192
193 # if the build system is known to allow the isystem modifier for library include
194 # values then use it for the boost libraries. Otherwise just add them to the
195 # regular CPPPATH values.
196 if env_cpp11['CXX'].startswith('g++') or env_cpp11['CXX'].startswith('clang'):
197     env_cpp11.Append(CPPFLAGS = '-isystem ' + env_cpp11['BOOST_INCLUDES'])
198 else:
199     env_cpp11.Append(CPPPATH = [env_cpp11['BOOST_INCLUDES']])
200 env_cpp11.Append(LIBPATH = [env_cpp11['BOOST_LIBS']])
201
202 releasedir = 'build/release/'
203 debugdir = 'build/debug/'
204 testdir = 'build/test/'
205 builddir = releasedir
206
207 Export('env')
208 Export('env_cpp11')
209 Export('platform_libs')
210 Export('boostlibs')
211 Export('tls_libs')
212 Export('polyfill_libs')
213
214 ## END OF CONFIG !!
215
216 ## TARGETS:
217
218 if not env['PLATFORM'].startswith('win'):
219     # Unit tests, add test folders with SConscript files to to_test list.
220     to_test = ['utility','http','logger','random','processors','message_buffer','extension','transport/iostream','transport/asio','roles','endpoint','connection','transport'] #,'http','processors','connection'
221
222     for t in to_test:
223        new_tests = SConscript('#/test/'+t+'/SConscript',variant_dir = testdir + t, duplicate = 0)
224        for a in new_tests:
225           new_alias = Alias('test', [a], a.abspath)
226           AlwaysBuild(new_alias)
227
228 # Main test application
229 #main = SConscript('#/examples/dev/SConscript',variant_dir = builddir + 'dev',duplicate = 0)
230
231 # echo_server
232 echo_server = SConscript('#/examples/echo_server/SConscript',variant_dir = builddir + 'echo_server',duplicate = 0)
233
234 # echo_client
235 echo_client = SConscript('#/examples/echo_client/SConscript',variant_dir = builddir + 'echo_client',duplicate = 0)
236
237 # echo_server_tls
238 if tls_build:
239     echo_server_tls = SConscript('#/examples/echo_server_tls/SConscript',variant_dir = builddir + 'echo_server_tls',duplicate = 0)
240     echo_server_both = SConscript('#/examples/echo_server_both/SConscript',variant_dir = builddir + 'echo_server_both',duplicate = 0)
241
242 # broadcast_server
243 broadcast_server = SConscript('#/examples/broadcast_server/SConscript',variant_dir = builddir + 'broadcast_server',duplicate = 0)
244
245 # testee_server
246 testee_server = SConscript('#/examples/testee_server/SConscript',variant_dir = builddir + 'testee_server',duplicate = 0)
247
248 # testee_client
249 testee_client = SConscript('#/examples/testee_client/SConscript',variant_dir = builddir + 'testee_client',duplicate = 0)
250
251 # scratch_client
252 scratch_client = SConscript('#/examples/scratch_client/SConscript',variant_dir = builddir + 'scratch_client',duplicate = 0)
253
254 # scratch_server
255 scratch_server = SConscript('#/examples/scratch_server/SConscript',variant_dir = builddir + 'scratch_server',duplicate = 0)
256
257
258 # debug_client
259 debug_client = SConscript('#/examples/debug_client/SConscript',variant_dir = builddir + 'debug_client',duplicate = 0)
260
261 # debug_server
262 debug_server = SConscript('#/examples/debug_server/SConscript',variant_dir = builddir + 'debug_server',duplicate = 0)
263
264 # subprotocol_server
265 subprotocol_server = SConscript('#/examples/subprotocol_server/SConscript',variant_dir = builddir + 'subprotocol_server',duplicate = 0)
266
267 # telemetry_server
268 telemetry_server = SConscript('#/examples/telemetry_server/SConscript',variant_dir = builddir + 'telemetry_server',duplicate = 0)
269
270 # external_io_service
271 external_io_service = SConscript('#/examples/external_io_service/SConscript',variant_dir = builddir + 'external_io_service',duplicate = 0)
272
273 if not env['PLATFORM'].startswith('win'):
274     # iostream_server
275     iostream_server = SConscript('#/examples/iostream_server/SConscript',variant_dir = builddir + 'iostream_server',duplicate = 0)
276
277     # telemetry_client
278     telemetry_client = SConscript('#/examples/telemetry_client/SConscript',variant_dir = builddir + 'telemetry_client',duplicate = 0)
279
280     # print_server
281     print_server = SConscript('#/examples/print_server/SConscript',variant_dir = builddir + 'print_server',duplicate = 0)