~ubuntu-branches/ubuntu/precise/libpgm/precise

« back to all changes in this revision

Viewing changes to openpgm/pgm/SConstruct.097.intelc

  • Committer: Bazaar Package Importer
  • Author(s): Gabriel de Perthuis
  • Date: 2011-04-07 16:48:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110407164852-8uamem42ojeptj6l
Tags: upstream-5.1.116~dfsg
ImportĀ upstreamĀ versionĀ 5.1.116~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- mode: python -*-
 
2
# OpenPGM build script
 
3
 
 
4
import platform
 
5
import os
 
6
import time
 
7
import sys
 
8
 
 
9
EnsureSConsVersion( 0, 97 )
 
10
SConsignFile('scons.signatures'+ '-' + platform.system() + '-' + platform.machine() + '-intelc');
 
11
 
 
12
opt = Options(None, ARGUMENTS)
 
13
opt.AddOptions (
 
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'))),
 
28
)
 
29
 
 
30
#-----------------------------------------------------------------------------
 
31
# Dependencies
 
32
 
 
33
def force_intelc(env):
 
34
        env.Tool('intelc', version='11.1', topdir='/opt/intel/Compiler/11.1/064/bin/intel64');
 
35
 
 
36
env = Environment();
 
37
force_intelc(env);
 
38
 
 
39
def CheckPKGConfig(context, version):
 
40
        context.Message( 'Checking for pkg-config... ' )
 
41
        ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
 
42
        context.Result( ret )
 
43
        return ret
 
44
 
 
45
def CheckPKG(context, name):
 
46
        context.Message( 'Checking for %s... ' % name )
 
47
        ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
 
48
        context.Result( ret )
 
49
        return ret
 
50
 
 
51
conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
 
52
                                       'CheckPKG' : CheckPKG })
 
53
 
 
54
if not conf.CheckPKGConfig('0.15.0'):
 
55
        print 'pkg-config >= 0.15.0 not found.'
 
56
#       Exit(1)
 
57
 
 
58
if not conf.CheckPKG('glib-2.0 >= 2.10'):
 
59
        print 'glib-2.0 >= 2.10 not found.'
 
60
#       Exit(1)
 
61
 
 
62
if not conf.CheckPKG('gthread-2.0'):
 
63
        print 'gthread-2.0 not found.'
 
64
#       Exit(1)
 
65
 
 
66
env = conf.Finish();
 
67
 
 
68
#-----------------------------------------------------------------------------
 
69
# Platform specifics
 
70
 
 
71
env = Environment(ENV = os.environ,
 
72
        CCFLAGS = [     '-pipe',
 
73
                        '-Wall',
 
74
#                               '-Wextra',
 
75
#                               '-Wfloat-equal',
 
76
                                '-Wshadow',
 
77
#                               '-Wunsafe-loop-optimizations',
 
78
                                '-Wpointer-arith',
 
79
#                               '-Wbad-function-cast',
 
80
#                               '-Wcast-qual',
 
81
#                               '-Wcast-align',
 
82
                                '-Wwrite-strings',
 
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',
 
91
#                               '-Wnested-externs',
 
92
# Verbose inlining reports
 
93
#                               '-Winline',
 
94
 
 
95
#  175: subscript out of range
 
96
#  - Ignored for broken compiler C99 support
 
97
#    e.g. tbuf[ sizeof(tbuf) ] = '\0';
 
98
                                '-wd175',
 
99
 
 
100
#  177: function was declared but never referenced
 
101
#  - Ignored as side effect of portability pre-processor blocks.
 
102
                                '-wd177',
 
103
 
 
104
#  181: argument is incompatible with corresponding format string conversion
 
105
#  - Ignored as pre-processor fails to parse variadic printf style macros.
 
106
                                '-wd181',
 
107
 
 
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;
 
111
                                '-wd191',
 
112
 
 
113
#  269: invalid format string conversion
 
114
#  - Ignored with failure to display PRIu32 with (volatile uint32_t)
 
115
                                '-wd269',
 
116
 
 
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;
 
120
                                '-wd556',
 
121
 
 
122
#  589: transfer of control bypasses initialization
 
123
#  - Ignored, it's a C++2003 error, perfectly valid in C99.
 
124
                                '-wd589',
 
125
 
 
126
#  593: variable was set but never used
 
127
#                               '-wd593',
 
128
 
 
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));
 
134
                                '-wd981',
 
135
 
 
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;
 
139
                                '-wd2259',
 
140
 
 
141
                        '-strict-ansi',
 
142
#                       '-pedantic',
 
143
# C99
 
144
                        '-std=c99',
 
145
                        '-D_XOPEN_SOURCE=600',
 
146
                        '-D_BSD_SOURCE',
 
147
# re-entrant libc
 
148
                        '-D_REENTRANT',
 
149
# POSIX spinlocks
 
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',
 
156
# variadic macros
 
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',
 
171
# timing
 
172
                        '-DCONFIG_HAVE_PSELECT',
 
173
# ioctl RTC_IRQP_SET: undefined reference to `__invalid_size_argument_for_IOC'
 
174
#                       '-DCONFIG_HAVE_RTC',
 
175
                        '-DCONFIG_HAVE_TSC',
 
176
# event handling
 
177
                        '-DCONFIG_HAVE_POLL',
 
178
                        '-DCONFIG_HAVE_EPOLL',
 
179
# interface enumeration
 
180
                        '-DCONFIG_HAVE_GETIFADDRS',
 
181
                        '-DCONFIG_HAVE_IFR_NETMASK',
 
182
# win32 cmsg
 
183
#                       '-DCONFIG_HAVE_WSACMSGHDR',
 
184
# multicast
 
185
                        '-DCONFIG_HAVE_MCAST_JOIN',
 
186
                        '-DCONFIG_HAVE_IP_MREQN',
 
187
# sprintf
 
188
                        '-DCONFIG_HAVE_SPRINTF_GROUPING',
 
189
                        '-DCONFIG_HAVE_VASPRINTF',
 
190
# symbol linking scope
 
191
                        '-DCONFIG_HAVE_DSO_VISIBILITY',
 
192
# socket binding
 
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',
 
205
# GNU getopt
 
206
                        '-DCONFIG_HAVE_GETOPT'
 
207
                 ],
 
208
        LINKFLAGS = [   '-pipe'
 
209
                    ],
 
210
        LIBS = [
 
211
# histogram math
 
212
                        'm',
 
213
# clock_gettime()
 
214
                        'rt'
 
215
                ],
 
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'
 
219
)
 
220
opt.Update (env)
 
221
force_intelc(env);
 
222
 
 
223
# Branch prediction
 
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')
 
229
 
 
230
# Coverage analysis
 
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')
 
236
 
 
237
# Define separate build environments
 
238
release = env.Clone(BUILD = 'release')
 
239
release.Append(CCFLAGS = '-O2')
 
240
 
 
241
debug = env.Clone(BUILD = 'debug')
 
242
debug.Append(CCFLAGS = ['-DPGM_DEBUG','-ggdb'], LINKFLAGS = '-ggdb')
 
243
 
 
244
profile = env.Clone(BUILD = 'profile')
 
245
profile.Append(CCFLAGS = ['-O0','-pg'], LINKFLAGS = '-pg')
 
246
 
 
247
thirtytwo = release.Clone(BUILD = 'thirtytwo')
 
248
thirtytwo.Append(CCFLAGS = '-m32', LINKFLAGS = '-m32')
 
249
 
 
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})
 
257
else:
 
258
        Export({'env':debug})
 
259
 
 
260
#-----------------------------------------------------------------------------
 
261
# Re-analyse dependencies
 
262
 
 
263
Import('env')
 
264
 
 
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');
 
268
else:
 
269
        env['GLIB_FLAGS'] = '';
 
270
 
 
271
# l10n
 
272
if env['WITH_GETTEXT'] == 'true':
 
273
        env.Append(CCFLAGS = '-DCONFIG_HAVE_GETTEXT');
 
274
 
 
275
# instrumentation
 
276
if env['WITH_HTTP'] == 'true' and env['WITH_HISTOGRAMS'] == 'true':
 
277
        env.Append(CCFLAGS = '-DCONFIG_HISTOGRAMS');
 
278
 
 
279
# managed environment for libpgmsnmp, libpgmhttp
 
280
if env['WITH_SNMP'] == 'true':
 
281
        env['SNMP_FLAGS'] = env.ParseFlags('!net-snmp-config --cflags --agent-libs');
 
282
 
 
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)
 
299
{
 
300
        init_agent("PGM");
 
301
        return 0;
 
302
}
 
303
""", '.c');
 
304
#       context.env.Replace(**backup);
 
305
        context.env.Replace(ASFLAGS     = lastASFLAGS,
 
306
                            CCFLAGS     = lastCCFLAGS,
 
307
                            CFLAGS      = lastCFLAGS,
 
308
                            CPPDEFINES  = lastCPPDEFINES,
 
309
                            CPPFLAGS    = lastCPPFLAGS,
 
310
                            CPPPATH     = lastCPPPATH,
 
311
                            LIBPATH     = lastLIBPATH,
 
312
                            LIBS        = lastLIBS,
 
313
                            LINKFLAGS   = lastLINKFLAGS,
 
314
                            RPATH       = lastRPATH);
 
315
        context.Result(not result);
 
316
        return result;
 
317
 
 
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);
 
322
        return result;
 
323
 
 
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)
 
329
{
 
330
        eventfd(0,0);
 
331
        return 0;
 
332
}
 
333
""", '.c')
 
334
        context.Result(result);
 
335
        return result;
 
336
 
 
337
tests = {
 
338
        'CheckCheck':   CheckCheck,
 
339
        'CheckEventFD': CheckEventFD
 
340
}
 
341
if env['WITH_SNMP'] == 'true':
 
342
        tests['CheckSNMP'] = CheckSNMP;
 
343
conf = Configure(env, custom_tests = tests);
 
344
 
 
345
if env['WITH_SNMP'] == 'true' and not conf.CheckSNMP():
 
346
        print 'Net-SNMP libraries not compatible.';
 
347
        Exit(1);
 
348
 
 
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');
 
353
else:
 
354
        print 'Disabling Check unit tests.';
 
355
        conf.env['CHECK'] = 'false';
 
356
 
 
357
if conf.CheckEventFD():
 
358
        print 'Enabling kernel eventfd notification mechanism.';
 
359
        conf.env.Append(CCFLAGS = '-DCONFIG_EVENTFD');
 
360
 
 
361
env = conf.Finish();
 
362
 
 
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});
 
375
 
 
376
 
 
377
#-----------------------------------------------------------------------------
 
378
 
 
379
ref_node = 'ref/' + env['BUILD'] + '-' + platform.system() + '-' + platform.machine() + '-intelc/';
 
380
BuildDir(ref_node, '.', duplicate=0)
 
381
 
 
382
env.Append(CPPPATH = os.getcwd() + '/include');
 
383
env.Append(LIBPATH = os.getcwd() + '/' + ref_node);
 
384
 
 
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');
 
396
 
 
397
# end of file