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

« back to all changes in this revision

Viewing changes to openpgm/pgm/.svn/text-base/SConstruct.Solaris.gcc64.svn-base

  • 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( 1, 0 )
 
10
SConsignFile('scons.signatures' + '-' + platform.system() + '-' + platform.machine() + '-gcc64');
 
11
 
 
12
vars = Variables()
 
13
vars.AddVariables (
 
14
        EnumVariable ('BUILD', 'build environment', 'debug',
 
15
                        allowed_values=('release', 'debug', 'profile', 'thirtytwo')),
 
16
        EnumVariable ('BRANCH', 'branch prediction', 'none',
 
17
                        allowed_values=('none', 'profile', 'seed')),
 
18
        EnumVariable ('WITH_GETTEXT', 'l10n support via libintl', 'false',
 
19
                        allowed_values=('true', 'false')),
 
20
        EnumVariable ('WITH_GLIB', 'Build GLib dependent modules', 'false',
 
21
                        allowed_values=('true', 'false')),
 
22
        EnumVariable ('WITH_HISTOGRAMS', 'Runtime statistical information', 'true',
 
23
                        allowed_values=('true', 'false')),
 
24
        EnumVariable ('WITH_HTTP', 'HTTP administration', 'false',
 
25
                        allowed_values=('true', 'false')),
 
26
        EnumVariable ('WITH_SNMP', 'SNMP administration', 'false',
 
27
                        allowed_values=('true', 'false')),
 
28
        EnumVariable ('WITH_CHECK', 'Check test system', 'false',
 
29
                        allowed_values=('true', 'false')),
 
30
        EnumVariable ('WITH_TEST', 'Network test system', 'false',
 
31
                        allowed_values=('true', 'false')),
 
32
        EnumVariable ('WITH_CC', 'C++ examples', 'true',
 
33
                        allowed_values=('true', 'false')),
 
34
        EnumVariable ('WITH_EXAMPLES', 'Examples', 'true',
 
35
                        allowed_values=('true', 'false')),
 
36
        EnumVariable ('WITH_NCURSES', 'NCURSES examples', 'false',
 
37
                        allowed_values=('true', 'false')),
 
38
        EnumVariable ('WITH_PROTOBUF', 'Google Protocol Buffer examples', 'false',
 
39
                        allowed_values=('true', 'false')),
 
40
        EnumVariable ('WITH_PLUS', 'libpgmplus GPL library', 'false',
 
41
                        allowed_values=('true', 'false')),
 
42
)
 
43
 
 
44
#-----------------------------------------------------------------------------
 
45
# Dependencies
 
46
 
 
47
def force_gcc(env):
 
48
        env.PrependENVPath('PATH', '/usr/sfw/bin');
 
49
        env.PrependENVPath('PATH', '/opt/glib-gcc64/bin');
 
50
        env.PrependENVPath('PATH', '/usr/local/bin');
 
51
        env.Tool('gcc');
 
52
        env.Tool('g++');
 
53
 
 
54
env = Environment();
 
55
force_gcc(env);
 
56
 
 
57
def CheckPKGConfig(context, version):
 
58
        context.Message( 'Checking for pkg-config... ' )
 
59
        ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
 
60
        context.Result( ret )
 
61
        return ret
 
62
 
 
63
def CheckPKG(context, name):
 
64
        context.Message( 'Checking for %s... ' % name )
 
65
        ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
 
66
        context.Result( ret )
 
67
        return ret
 
68
 
 
69
conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
 
70
                                       'CheckPKG' : CheckPKG })
 
71
 
 
72
if not conf.CheckPKGConfig('0.15.0'):
 
73
        print 'pkg-config >= 0.15.0 not found.'
 
74
#       Exit(1)
 
75
 
 
76
if not conf.CheckPKG('glib-2.0 >= 2.10'):
 
77
        print 'glib-2.0 >= 2.10 not found.'
 
78
#       Exit(1)
 
79
 
 
80
if not conf.CheckPKG('gthread-2.0'):
 
81
        print 'gthread-2.0 not found.'
 
82
#       Exit(1)
 
83
 
 
84
env = conf.Finish();
 
85
 
 
86
#-----------------------------------------------------------------------------
 
87
# Platform specifics
 
88
 
 
89
env = Environment(
 
90
        variables = vars,
 
91
        ENV = os.environ,
 
92
        CCFLAGS = [     '-pipe',
 
93
                        '-Wall',
 
94
                                '-Wextra',
 
95
                                '-Wfloat-equal',
 
96
                                '-Wshadow',
 
97
#                               '-Wunsafe-loop-optimizations',
 
98
                                '-Wpointer-arith',
 
99
                                '-Wbad-function-cast',
 
100
                                '-Wcast-qual',
 
101
                                '-Wcast-align',
 
102
                                '-Wwrite-strings',
 
103
                                '-Waggregate-return',
 
104
                                '-Wstrict-prototypes',
 
105
                                '-Wold-style-definition',
 
106
                                '-Wmissing-prototypes',
 
107
                                '-Wmissing-declarations',
 
108
                                '-Wmissing-noreturn',
 
109
                                '-Wmissing-format-attribute',
 
110
                                '-Wredundant-decls',
 
111
                                '-Wnested-externs',
 
112
#                               '-Winline',
 
113
                                '-Wno-inline',
 
114
                                '-Wno-unused-function',
 
115
                        '-pedantic',
 
116
# C99
 
117
                        '-std=gnu99',
 
118
                        '-D_XOPEN_SOURCE=600',
 
119
                        '-D__EXTENSIONS__',
 
120
# re-entrant libc
 
121
                        '-D_REENTRANT',
 
122
# POSIX spinlocks
 
123
                        '-DCONFIG_HAVE_POSIX_SPINLOCK',
 
124
# NSS protocol lookup
 
125
                        '-DCONFIG_HAVE_GETPROTOBYNAME_R',
 
126
#                       '-DCONFIG_HAVE_GETPROTOBYNAME_R2',
 
127
# NSS networks lookup, IPv4 only
 
128
                        '-DCONFIG_HAVE_GETNETENT',
 
129
# variadic macros
 
130
                        '-DCONFIG_HAVE_ISO_VARARGS',
 
131
#                       '-DCONFIG_HAVE_GNUC_VARARGS',
 
132
# stack memory api header
 
133
                        '-DCONFIG_HAVE_ALLOCA_H',
 
134
# optimium checksum implementation
 
135
#                       '-DCONFIG_8BIT_CHECKSUM',
 
136
                        '-DCONFIG_16BIT_CHECKSUM',
 
137
#                       '-DCONFIG_32BIT_CHECKSUM',
 
138
#                       '-DCONFIG_64BIT_CHECKSUM',
 
139
#                       '-DCONFIG_VECTOR_CHECKSUM',
 
140
# useful /proc system
 
141
#                       '-DCONFIG_HAVE_PROC',
 
142
# example: crash handling
 
143
#                       '-DCONFIG_HAVE_BACKTRACE',
 
144
# timing
 
145
#                       '-DCONFIG_HAVE_PSELECT',
 
146
#                       '-DCONFIG_HAVE_RTC',
 
147
#                       '-DCONFIG_HAVE_TSC',
 
148
#                       '-DCONFIG_HAVE_HPET',
 
149
# event handling
 
150
                        '-DCONFIG_HAVE_POLL',
 
151
#                       '-DCONFIG_HAVE_EPOLL',
 
152
# interface enumeration
 
153
#                       '-DCONFIG_HAVE_GETIFADDRS',
 
154
#                       '-DCONFIG_HAVE_IFR_NETMASK',
 
155
# win32 cmsg
 
156
#                       '-DCONFIG_HAVE_WSACMSGHDR',
 
157
# multicast
 
158
                        '-DCONFIG_HAVE_MCAST_JOIN',
 
159
#                       '-DCONFIG_HAVE_IP_MREQN',
 
160
# sprintf
 
161
#                       '-DCONFIG_HAVE_SPRINTF_GROUPING',
 
162
#                       '-DCONFIG_HAVE_VASPRINTF',
 
163
# symbol linking scope
 
164
#                       '-DCONFIG_HAVE_DSO_VISIBILITY',
 
165
# socket binding
 
166
                        '-DCONFIG_BIND_INADDR_ANY',
 
167
# IP header order as per IP(4) on FreeBSD
 
168
#                       '-DCONFIG_HOST_ORDER_IP_LEN',
 
169
#                       '-DCONFIG_HOST_ORDER_IP_OFF',
 
170
# ticket based spinlocks
 
171
                        '-DCONFIG_TICKET_SPINLOCK',
 
172
# dumb read-write spinlock
 
173
                        '-DCONFIG_DUMB_RWSPINLOCK',
 
174
# optimum galois field multiplication
 
175
                        '-DCONFIG_GALOIS_MUL_LUT',
 
176
# Wine limited API support
 
177
#                       '-DCONFIG_TARGET_WINE',
 
178
# GNU getopt
 
179
                        '-DCONFIG_HAVE_GETOPT'
 
180
                 ],
 
181
        LINKFLAGS = [   '-pipe'
 
182
                ],
 
183
        LIBS = [
 
184
# histogram math
 
185
                        'm',
 
186
# clock_gettime()
 
187
                        'rt',
 
188
# Solaris sockets
 
189
                        'resolv',
 
190
                        'socket',
 
191
                        'nsl'
 
192
                    ],
 
193
        PROTOBUF_CCFLAGS = '-I/opt/glib-gcc64/include',
 
194
        PROTOBUF_LIBS    = '/opt/glib-gcc64/lib/sparcv9/libprotobuf.a',
 
195
        PROTOBUF_PROTOC  = '/opt/glib-gcc64/bin/protoc'
 
196
)
 
197
force_gcc(env);
 
198
 
 
199
# Branch prediction
 
200
if env['BRANCH'] == 'profile':
 
201
        env.Append(CCFLAGS = '-fprofile-arcs')
 
202
        env.Append(LINKFLAGS = '-fprofile-arcs')
 
203
elif env['BRANCH'] == 'seed':
 
204
        env.Append(CCFLAGS = '-fbranch-probabilities')
 
205
 
 
206
# Define separate build environments
 
207
release = env.Clone(BUILD = 'release')
 
208
release.Append(CCFLAGS = ['-O2','-m64'], LINKFLAGS = '-m64')
 
209
 
 
210
debug = env.Clone(BUILD = 'debug')
 
211
debug.Append(CCFLAGS = ['-DPGM_DEBUG','-ggdb','-m64'], LINKFLAGS = ['-gdb','-m64'])
 
212
 
 
213
profile = env.Clone(BUILD = 'profile')
 
214
profile.Append(CCFLAGS = ['-O2','-pg','-m64'], LINKFLAGS = ['-pg','-m64'])
 
215
 
 
216
thirtytwo = env.Clone(BUILD = 'thirtytwo')
 
217
thirtytwo.Append(CCFLAGS = ['-O2','-m32'], LINKFLAGS = '-m32')
 
218
 
 
219
# choose and environment to build
 
220
if env['BUILD'] == 'release':
 
221
        Export({'env':release})
 
222
elif env['BUILD'] == 'profile':
 
223
        Export({'env':profile})
 
224
elif env['BUILD'] == 'thirtytwo':
 
225
        Export({'env':thirtytwo})
 
226
else:
 
227
        Export({'env':debug})
 
228
 
 
229
#-----------------------------------------------------------------------------
 
230
# Re-analyse dependencies
 
231
 
 
232
Import('env')
 
233
 
 
234
# vanilla environment
 
235
if env['WITH_GLIB'] == 'true':
 
236
        env['GLIB_FLAGS'] = env.ParseFlags('!pkg-config --cflags --libs glib-2.0 gthread-2.0');
 
237
else:
 
238
        env['GLIB_FLAGS'] = '';
 
239
 
 
240
# l10n
 
241
if env['WITH_GETTEXT'] == 'true':
 
242
        env.Append(CCFLAGS = '-DCONFIG_HAVE_GETTEXT');
 
243
 
 
244
# instrumentation
 
245
if env['WITH_HTTP'] == 'true' and env['WITH_HISTOGRAMS'] == 'true':
 
246
        env.Append(CCFLAGS = '-DCONFIG_HISTOGRAMS');
 
247
 
 
248
def list_remove(list, target):
 
249
        newlist = [];
 
250
        for item in str(list).split(' '):
 
251
                if item != target:
 
252
                        newlist.append(item);
 
253
        return newlist;
 
254
 
 
255
# managed environment for libpgmsnmp, libpgmhttp
 
256
if env['WITH_SNMP'] == 'true':
 
257
# net-snmp-config is broken in Solaris 10 and requires two separate calls
 
258
        env['SNMP_FLAGS'] = env.ParseFlags(['!net-snmp-config-64 --cflags',
 
259
                                            '!net-snmp-config-64 --agent-libs']);
 
260
# GCC error: language arch=v9 not recognized
 
261
        ccflags = env['SNMP_FLAGS'].get('CCFLAGS', '');
 
262
        env['SNMP_FLAGS']['CCFLAGS'] = list_remove(ccflags, '-xarch=v9');
 
263
 
 
264
def CheckSNMP(context):
 
265
        context.Message('Checking Net-SNMP...');
 
266
#       backup = context.env.Clone().Dictionary();
 
267
        lastASFLAGS     = context.env.get('ASFLAGS', '');
 
268
        lastCCFLAGS     = context.env.get('CCFLAGS', '');
 
269
        lastCFLAGS      = context.env.get('CFLAGS', '');
 
270
        lastCPPDEFINES  = context.env.get('CPPDEFINES', '');
 
271
        lastCPPFLAGS    = context.env.get('CPPFLAGS', '');
 
272
        lastCPPPATH     = context.env.get('CPPPATH', '');
 
273
        lastLIBPATH     = context.env.get('LIBPATH', '');
 
274
        lastLIBS        = context.env.get('LIBS', '');
 
275
        lastLINKFLAGS   = context.env.get('LINKFLAGS', '');
 
276
        lastRPATH       = context.env.get('RPATH', '');
 
277
        context.env.MergeFlags(env['SNMP_FLAGS']);
 
278
        result = context.TryLink("""
 
279
int main(int argc, char**argv)
 
280
{
 
281
        init_agent("PGM");
 
282
        return 0;
 
283
}
 
284
""", '.c');
 
285
#       context.env.Replace(**backup);
 
286
        context.env.Replace(ASFLAGS     = lastASFLAGS,
 
287
                            CCFLAGS     = lastCCFLAGS,
 
288
                            CFLAGS      = lastCFLAGS,
 
289
                            CPPDEFINES  = lastCPPDEFINES,
 
290
                            CPPFLAGS    = lastCPPFLAGS,
 
291
                            CPPPATH     = lastCPPPATH,
 
292
                            LIBPATH     = lastLIBPATH,
 
293
                            LIBS        = lastLIBS,
 
294
                            LINKFLAGS   = lastLINKFLAGS,
 
295
                            RPATH       = lastRPATH);
 
296
        context.Result(not result);
 
297
        return result;
 
298
 
 
299
def CheckCheck(context):
 
300
        context.Message('Checking Check unit test framework...');
 
301
        result = context.TryAction('pkg-config --cflags --libs check')[0];
 
302
        context.Result(result);
 
303
        return result;
 
304
 
 
305
tests = {
 
306
        'CheckCheck':   CheckCheck
 
307
}
 
308
if env['WITH_SNMP'] == 'true':
 
309
        tests['CheckSNMP'] = CheckSNMP;
 
310
conf = Configure(env, custom_tests = tests);
 
311
 
 
312
if env['WITH_SNMP'] == 'true' and not conf.CheckSNMP():
 
313
        print 'Net-SNMP libraries not compatible.';
 
314
        Exit(1);
 
315
 
 
316
if env['WITH_CHECK'] == 'true' and conf.CheckCheck():
 
317
        print 'Enabling Check unit tests.';
 
318
        conf.env['CHECK'] = 'true';
 
319
        env['CHECK_FLAGS'] = env.ParseFlags('!pkg-config --cflags --libs check');
 
320
else:
 
321
        print 'Disabling Check unit tests.';
 
322
        conf.env['CHECK'] = 'false';
 
323
 
 
324
env = conf.Finish();
 
325
 
 
326
# add builder to create PIC static libraries for including in shared libraries
 
327
action_list = [ Action("$ARCOM", "$ARCOMSTR") ];
 
328
if env.Detect('ranlib'):
 
329
        ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR");
 
330
        action_list.append(ranlib_action);
 
331
pic_lib = Builder(      action = action_list,
 
332
                        emitter = '$LIBEMITTER',
 
333
                        prefix = '$LIBPREFIX',
 
334
                        suffix = '$LIBSUFFIX',
 
335
                        src_suffix = '$OBJSUFFIX',
 
336
                        src_builder = 'SharedObject')
 
337
env.Append(BUILDERS = {'StaticSharedLibrary': pic_lib});
 
338
 
 
339
 
 
340
#-----------------------------------------------------------------------------
 
341
 
 
342
ref_node = 'ref/' + env['BUILD'] + '-' + platform.system() + '-' + platform.machine() + '-gcc64/';
 
343
BuildDir(ref_node, '.', duplicate=0)
 
344
 
 
345
env.Append(CPPPATH = os.getcwd() + '/include');
 
346
env.Append(LIBPATH = os.getcwd() + '/' + ref_node);
 
347
 
 
348
if env['WITH_GLIB'] == 'true':
 
349
        SConscript(ref_node + 'SConscript.libpgmex');
 
350
SConscript(ref_node + 'SConscript.libpgm');
 
351
if env['WITH_HTTP'] == 'true':
 
352
        SConscript(ref_node + 'SConscript.libpgmhttp');
 
353
if env['WITH_SNMP'] == 'true':
 
354
        SConscript(ref_node + 'SConscript.libpgmsnmp');
 
355
if env['WITH_TEST'] == 'true':
 
356
        SConscript(ref_node + 'test/SConscript');
 
357
if env['WITH_EXAMPLES'] == 'true':
 
358
        SConscript(ref_node + 'examples/SConscript');
 
359
 
 
360
# end of file