9
EnsureSConsVersion( 0, 97 )
10
SConsignFile('scons.signatures'+ '-' + platform.system() + '-' + platform.machine() + '-intelc');
12
opt = Options(None, ARGUMENTS)
14
(EnumOption ('BUILD', 'build environment', 'debug', ('release', 'debug', 'profile'))),
15
(EnumOption ('BRANCH', 'branch prediction', 'none', ('none', 'profile', 'seed'))),
16
(EnumOption ('WITH_GETTEXT', 'l10n support via libintl', 'false', ('true', 'false'))),
17
(EnumOption ('WITH_GLIB', 'Build GLib dependent modules', 'false', ('true', 'false'))),
18
(EnumOption ('COVERAGE', 'test coverage', 'none', ('none', 'full'))),
19
(EnumOption ('WITH_HISTOGRAMS', 'Runtime statistical information', 'true', ('true', 'false'))),
20
(EnumOption ('WITH_HTTP', 'HTTP administration', 'false', ('true', 'false'))),
21
(EnumOption ('WITH_SNMP', 'SNMP administration', 'false', ('true', 'false'))),
22
(EnumOption ('WITH_CHECK', 'Check test system', 'false', ('true', 'false'))),
23
(EnumOption ('WITH_TEST', 'Network test system', 'false', ('true', 'false'))),
24
(EnumOption ('WITH_CC', 'C++ Examples', 'true', ('true', 'false'))),
25
(EnumOption ('WITH_EXAMPLES', 'Examples', 'true', ('true', 'false'))),
26
(EnumOption ('WITH_NCURSES', 'NCURSES examples', 'false', ('true', 'false'))),
27
(EnumOption ('WITH_PROTOBUF', 'Google Protocol Buffer examples', 'false', ('true', 'false'))),
30
#-----------------------------------------------------------------------------
33
def force_intelc(env):
34
env.Tool('intelc', version='11.1', topdir='/opt/intel/Compiler/11.1/064/bin/intel64');
39
def CheckPKGConfig(context, version):
40
context.Message( 'Checking for pkg-config... ' )
41
ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
45
def CheckPKG(context, name):
46
context.Message( 'Checking for %s... ' % name )
47
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
51
conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
52
'CheckPKG' : CheckPKG })
54
if not conf.CheckPKGConfig('0.15.0'):
55
print 'pkg-config >= 0.15.0 not found.'
58
if not conf.CheckPKG('glib-2.0 >= 2.10'):
59
print 'glib-2.0 >= 2.10 not found.'
62
if not conf.CheckPKG('gthread-2.0'):
63
print 'gthread-2.0 not found.'
68
#-----------------------------------------------------------------------------
71
env = Environment(ENV = os.environ,
77
# '-Wunsafe-loop-optimizations',
79
# '-Wbad-function-cast',
83
# '-Waggregate-return',
84
'-Wstrict-prototypes',
85
# '-Wold-style-definition',
86
'-Wmissing-prototypes',
87
'-Wmissing-declarations',
88
# '-Wmissing-noreturn',
89
# '-Wmissing-format-attribute',
90
# '-Wredundant-decls',
92
# Verbose inlining reports
95
# 175: subscript out of range
96
# - Ignored for broken compiler C99 support
97
# e.g. tbuf[ sizeof(tbuf) ] = '\0';
100
# 177: function was declared but never referenced
101
# - Ignored as side effect of portability pre-processor blocks.
104
# 181: argument is incompatible with corresponding format string conversion
105
# - Ignored as pre-processor fails to parse variadic printf style macros.
108
# 191: type qualifier is meaningless on cast type
109
# - Ignored as cast required for portability
110
# e.g. pgm_txw_state_t*const state = (pgm_txw_state_t*const)&skb->cb;
113
# 269: invalid format string conversion
114
# - Ignored with failure to display PRIu32 with (volatile uint32_t)
117
# 556: cannot assign to an entity of type "void *"
118
# - Ignored, it's a C++2003 error, valid in C99 aside of const down-converting.
119
# e.g. const char *s = ""; void *p = s;
122
# 589: transfer of control bypasses initialization
123
# - Ignored, it's a C++2003 error, perfectly valid in C99.
126
# 593: variable was set but never used
129
# 981: operands are evaluated in unspecified order
130
# - Ignored as pedantic warning against possible side effects.
131
# e.g. printf ("%s.%s > ",
132
# pgm_gethostbyaddr((const struct in_addr*)&ip->ip_src),
133
# pgm_udpport_string(pgm_header->pgm_sport));
136
# 2259: non-pointer conversion from "/type a/" to "/type b/" may lose significant bits
137
# - Ignored for really pedantic compiler temporary value conversions,
138
# e.g. uint16_t j = 1, i = ~j;
145
'-D_XOPEN_SOURCE=600',
150
'-DCONFIG_HAVE_POSIX_SPINLOCK',
151
# NSS protocol lookup
152
# '-DCONFIG_HAVE_GETPROTOBYNAME_R',
153
'-DCONFIG_HAVE_GETPROTOBYNAME_R2',
154
# NSS networks lookup, IPv4 only
155
'-DCONFIG_HAVE_GETNETENT',
157
'-DCONFIG_HAVE_ISO_VARARGS',
158
# '-DCONFIG_HAVE_GNUC_VARARGS',
159
# stack memory api header
160
'-DCONFIG_HAVE_ALLOCA_H',
161
# optimium checksum implementation
162
# '-DCONFIG_8BIT_CHECKSUM',
163
'-DCONFIG_16BIT_CHECKSUM',
164
# '-DCONFIG_32BIT_CHECKSUM',
165
# '-DCONFIG_64BIT_CHECKSUM',
166
# '-DCONFIG_VECTOR_CHECKSUM',
167
# useful /proc system
168
'-DCONFIG_HAVE_PROC',
169
# example: crash handling
170
'-DCONFIG_HAVE_BACKTRACE',
172
'-DCONFIG_HAVE_PSELECT',
173
# ioctl RTC_IRQP_SET: undefined reference to `__invalid_size_argument_for_IOC'
174
# '-DCONFIG_HAVE_RTC',
177
'-DCONFIG_HAVE_POLL',
178
'-DCONFIG_HAVE_EPOLL',
179
# interface enumeration
180
'-DCONFIG_HAVE_GETIFADDRS',
181
'-DCONFIG_HAVE_IFR_NETMASK',
183
# '-DCONFIG_HAVE_WSACMSGHDR',
185
'-DCONFIG_HAVE_MCAST_JOIN',
186
'-DCONFIG_HAVE_IP_MREQN',
188
'-DCONFIG_HAVE_SPRINTF_GROUPING',
189
'-DCONFIG_HAVE_VASPRINTF',
190
# symbol linking scope
191
'-DCONFIG_HAVE_DSO_VISIBILITY',
193
'-DCONFIG_BIND_INADDR_ANY',
194
# IP header order as per IP(4) on FreeBSD
195
# '-DCONFIG_HOST_ORDER_IP_LEN',
196
# '-DCONFIG_HOST_ORDER_IP_OFF',
197
# ticket based spinlocks
198
'-DCONFIG_TICKET_SPINLOCK',
199
# dumb read-write spinlock
200
'-DCONFIG_DUMB_RWSPINLOCK',
201
# optimum galois field multiplication
202
'-DCONFIG_GALOIS_MUL_LUT',
203
# Wine limited API support
204
# '-DCONFIG_TARGET_WINE',
206
'-DCONFIG_HAVE_GETOPT'
208
LINKFLAGS = [ '-pipe'
216
PROTOBUF_CCFLAGS = '-I/miru/projects/protobuf/protobuf-2.1.0/src',
217
PROTOBUF_LIBS = '/miru/projects/protobuf/protobuf-2.1.0/src/.libs/libprotobuf.a',
218
PROTOBUF_PROTOC = '/miru/projects/protobuf/protobuf-2.1.0/src/protoc'
224
if env['BRANCH'] == 'profile':
225
env.Append(CCFLAGS = '-fprofile-arcs')
226
env.Append(LINKFLAGS = '-fprofile-arcs')
227
elif env['BRANCH'] == 'seed':
228
env.Append(CCFLAGS = '-fbranch-probabilities')
231
if env['COVERAGE'] == 'full':
232
env.Append(CCFLAGS = '-fprofile-arcs')
233
env.Append(CCFLAGS = '-ftest-coverage')
234
env.Append(LINKFLAGS = '-fprofile-arcs')
235
env.Append(LINKFLAGS = '-lgcov')
237
# Define separate build environments
238
release = env.Clone(BUILD = 'release')
239
release.Append(CCFLAGS = '-O2')
241
debug = env.Clone(BUILD = 'debug')
242
debug.Append(CCFLAGS = ['-DPGM_DEBUG','-ggdb'], LINKFLAGS = '-ggdb')
244
profile = env.Clone(BUILD = 'profile')
245
profile.Append(CCFLAGS = ['-O0','-pg'], LINKFLAGS = '-pg')
247
thirtytwo = release.Clone(BUILD = 'thirtytwo')
248
thirtytwo.Append(CCFLAGS = '-m32', LINKFLAGS = '-m32')
250
# choose and environment to build
251
if env['BUILD'] == 'release':
252
Export({'env':release})
253
elif env['BUILD'] == 'profile':
254
Export({'env':profile})
255
elif env['BUILD'] == 'thirtytwo':
256
Export({'env':thirtytwo})
258
Export({'env':debug})
260
#-----------------------------------------------------------------------------
261
# Re-analyse dependencies
265
# vanilla environment
266
if env['WITH_GLIB'] == 'true':
267
env['GLIB_FLAGS'] = env.ParseFlags('!pkg-config --cflags --libs glib-2.0 gthread-2.0');
269
env['GLIB_FLAGS'] = '';
272
if env['WITH_GETTEXT'] == 'true':
273
env.Append(CCFLAGS = '-DCONFIG_HAVE_GETTEXT');
276
if env['WITH_HTTP'] == 'true' and env['WITH_HISTOGRAMS'] == 'true':
277
env.Append(CCFLAGS = '-DCONFIG_HISTOGRAMS');
279
# managed environment for libpgmsnmp, libpgmhttp
280
if env['WITH_SNMP'] == 'true':
281
env['SNMP_FLAGS'] = env.ParseFlags('!net-snmp-config --cflags --agent-libs');
283
def CheckSNMP(context):
284
context.Message('Checking Net-SNMP...');
285
# backup = context.env.Clone().Dictionary();
286
lastASFLAGS = context.env.get('ASFLAGS', '');
287
lastCCFLAGS = context.env.get('CCFLAGS', '');
288
lastCFLAGS = context.env.get('CFLAGS', '');
289
lastCPPDEFINES = context.env.get('CPPDEFINES', '');
290
lastCPPFLAGS = context.env.get('CPPFLAGS', '');
291
lastCPPPATH = context.env.get('CPPPATH', '');
292
lastLIBPATH = context.env.get('LIBPATH', '');
293
lastLIBS = context.env.get('LIBS', '');
294
lastLINKFLAGS = context.env.get('LINKFLAGS', '');
295
lastRPATH = context.env.get('RPATH', '');
296
context.env.MergeFlags(env['SNMP_FLAGS']);
297
result = context.TryLink("""
298
int main(int argc, char**argv)
304
# context.env.Replace(**backup);
305
context.env.Replace(ASFLAGS = lastASFLAGS,
306
CCFLAGS = lastCCFLAGS,
308
CPPDEFINES = lastCPPDEFINES,
309
CPPFLAGS = lastCPPFLAGS,
310
CPPPATH = lastCPPPATH,
311
LIBPATH = lastLIBPATH,
313
LINKFLAGS = lastLINKFLAGS,
315
context.Result(not result);
318
def CheckCheck(context):
319
context.Message('Checking Check unit test framework...');
320
result = context.TryAction('pkg-config --cflags --libs check')[0];
321
context.Result(result);
324
def CheckEventFD(context):
325
context.Message('Checking eventfd...');
326
result = context.TryLink("""
327
#include <sys/eventfd.h>
328
int main(int argc, char**argv)
334
context.Result(result);
338
'CheckCheck': CheckCheck,
339
'CheckEventFD': CheckEventFD
341
if env['WITH_SNMP'] == 'true':
342
tests['CheckSNMP'] = CheckSNMP;
343
conf = Configure(env, custom_tests = tests);
345
if env['WITH_SNMP'] == 'true' and not conf.CheckSNMP():
346
print 'Net-SNMP libraries not compatible.';
349
if env['WITH_CHECK'] == 'true' and conf.CheckCheck():
350
print 'Enabling Check unit tests.';
351
conf.env['CHECK'] = 'true';
352
env['CHECK_FLAGS'] = env.ParseFlags('!pkg-config --cflags --libs check');
354
print 'Disabling Check unit tests.';
355
conf.env['CHECK'] = 'false';
357
if conf.CheckEventFD():
358
print 'Enabling kernel eventfd notification mechanism.';
359
conf.env.Append(CCFLAGS = '-DCONFIG_EVENTFD');
363
# add builder to create PIC static libraries for including in shared libraries
364
action_list = [ Action("$ARCOM", "$ARCOMSTR") ];
365
if env.Detect('ranlib'):
366
ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR");
367
action_list.append(ranlib_action);
368
pic_lib = Builder( action = action_list,
369
emitter = '$LIBEMITTER',
370
prefix = '$LIBPREFIX',
371
suffix = '$LIBSUFFIX',
372
src_suffix = '$OBJSUFFIX',
373
src_builder = 'SharedObject')
374
env.Append(BUILDERS = {'StaticSharedLibrary': pic_lib});
377
#-----------------------------------------------------------------------------
379
ref_node = 'ref/' + env['BUILD'] + '-' + platform.system() + '-' + platform.machine() + '-intelc/';
380
BuildDir(ref_node, '.', duplicate=0)
382
env.Append(CPPPATH = os.getcwd() + '/include');
383
env.Append(LIBPATH = os.getcwd() + '/' + ref_node);
385
if env['WITH_GLIB'] == 'true':
386
SConscript(ref_node + 'SConscript.libpgmex');
387
SConscript(ref_node + 'SConscript.libpgm');
388
if env['WITH_HTTP'] == 'true':
389
SConscript(ref_node + 'SConscript.libpgmhttp');
390
if env['WITH_SNMP'] == 'true':
391
SConscript(ref_node + 'SConscript.libpgmsnmp');
392
if env['WITH_TEST'] == 'true':
393
SConscript(ref_node + 'test/SConscript');
394
if env['WITH_EXAMPLES'] == 'true':
395
SConscript(ref_node + 'examples/SConscript');