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

« back to all changes in this revision

Viewing changes to openpgm/pgm/SConstruct.OpenSolaris

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