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

« back to all changes in this revision

Viewing changes to openpgm/pgm/.svn/text-base/SConstruct.Debian4.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 os
 
5
import time
 
6
import sys
 
7
 
 
8
EnsureSConsVersion( 0, 97 )
 
9
SConsignFile('scons.signatures');
 
10
 
 
11
opt = Options(None, ARGUMENTS)
 
12
opt.AddOptions (
 
13
        (EnumOption ('BUILD', 'build environment', 'debug', ('release', 'debug', 'profile'))),
 
14
        (EnumOption ('BRANCH', 'branch prediction', 'none', ('none', 'profile', 'seed'))),
 
15
        (EnumOption ('COVERAGE', 'test coverage', 'none', ('none', 'full'))),
 
16
        (EnumOption ('WITH_HISTOGRAMS', 'Runtime statistical information', 'true', ('true', 'false'))),
 
17
        (EnumOption ('WITH_HTTP', 'HTTP administration', 'true', ('true', 'false'))),
 
18
        (EnumOption ('WITH_SNMP', 'SNMP administration', 'true', ('true', 'false'))),
 
19
        (EnumOption ('WITH_CHECK', 'Check test system', 'false', ('true', 'false'))),
 
20
        (EnumOption ('WITH_TEST', 'Network test system', 'false', ('true', 'false'))),
 
21
        (EnumOption ('WITH_EXAMPLES', 'Examples', 'true', ('true', 'false'))),
 
22
        (EnumOption ('WITH_NCURSES', 'NCURSES examples', 'false', ('true', 'false'))),
 
23
        (EnumOption ('WITH_PROTOBUF', 'Google Protocol Buffer examples', 'false', ('true', 'false'))),
 
24
        (EnumOption ('WITH_PLUS', 'libpgmplus GPL library', 'false', ('true', 'false'))),
 
25
)
 
26
 
 
27
#-----------------------------------------------------------------------------
 
28
# Dependencies
 
29
 
 
30
env = Environment();
 
31
 
 
32
def CheckPKGConfig(context, version):
 
33
        context.Message( 'Checking for pkg-config... ' )
 
34
        ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
 
35
        context.Result( ret )
 
36
        return ret
 
37
 
 
38
def CheckPKG(context, name):
 
39
        context.Message( 'Checking for %s... ' % name )
 
40
        ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
 
41
        context.Result( ret )
 
42
        return ret
 
43
 
 
44
conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
 
45
                                       'CheckPKG' : CheckPKG })
 
46
 
 
47
if not conf.CheckPKGConfig('0.15.0'):
 
48
        print 'pkg-config >= 0.15.0 not found.'
 
49
        Exit(1)
 
50
 
 
51
if not conf.CheckPKG('glib-2.0 >= 2.10'):
 
52
        print 'glib-2.0 >= 2.10 not found.'
 
53
        Exit(1)
 
54
 
 
55
if not conf.CheckPKG('gthread-2.0'):
 
56
        print 'gthread-2.0 not found.'
 
57
        Exit(1)
 
58
 
 
59
env = conf.Finish();
 
60
 
 
61
#-----------------------------------------------------------------------------
 
62
# Platform specifics
 
63
 
 
64
env = Environment(ENV = os.environ,
 
65
        CCFLAGS = [     '-pipe',
 
66
                        '-Wall',
 
67
                                '-Wextra',
 
68
                                '-Wfloat-equal',
 
69
                                '-Wshadow',
 
70
                                '-Wunsafe-loop-optimizations',
 
71
                                '-Wpointer-arith',
 
72
                                '-Wbad-function-cast',
 
73
                                '-Wcast-qual',
 
74
                                '-Wcast-align',
 
75
                                '-Wwrite-strings',
 
76
                                '-Waggregate-return',
 
77
                                '-Wstrict-prototypes',
 
78
                                '-Wold-style-definition',
 
79
                                '-Wmissing-prototypes',
 
80
                                '-Wmissing-declarations',
 
81
                                '-Wmissing-noreturn',
 
82
                                '-Wmissing-format-attribute',
 
83
                                '-Wredundant-decls',
 
84
                                '-Wnested-externs',
 
85
                                '-Winline',
 
86
                        '-pedantic',
 
87
                        '-std=gnu99',
 
88
                        '--param', 'max-inline-insns-single=600',
 
89
                        '-D_REENTRANT',
 
90
                        '-D_GNU_SOURCE',
 
91
                        '-D__need_IOV_MAX',
 
92
                        '-DCONFIG_16BIT_CHECKSUM',
 
93
                        '-DCONFIG_HAVE_PROC',
 
94
                        '-DCONFIG_HAVE_BACKTRACE',
 
95
                        '-DCONFIG_HAVE_PSELECT',
 
96
                        '-DCONFIG_HAVE_POLL',
 
97
                        '-DCONFIG_HAVE_EPOLL',
 
98
                        '-DCONFIG_HAVE_CLOCK_GETTIME',
 
99
                        '-DCONFIG_HAVE_CLOCK_NANOSLEEP',
 
100
                        '-DCONFIG_HAVE_NANOSLEEP',
 
101
                        '-DCONFIG_HAVE_USLEEP',
 
102
                        '-DCONFIG_HAVE_RTC',
 
103
                        '-DCONFIG_HAVE_TSC',
 
104
                        '-DCONFIG_HAVE_IFR_NETMASK',
 
105
                        '-DCONFIG_HAVE_GETIFADDRS',
 
106
                        '-DCONFIG_HAVE_GETHOSTBYNAME2',
 
107
                        '-DCONFIG_HAVE_GETPROTOBYNAME_R',
 
108
                        '-DCONFIG_HAVE_MCAST_JOIN',
 
109
                        '-DCONFIG_HAVE_IP_MREQN',
 
110
                        '-DCONFIG_HAVE_DSO_VISIBILITY',
 
111
                        '-DCONFIG_BIND_INADDR_ANY',
 
112
                        '-DCONFIG_GALOIS_MUL_LUT',
 
113
                 ],
 
114
        LINKFLAGS = [   '-pipe',
 
115
                        '-lm'
 
116
                    ]
 
117
)
 
118
opt.Update (env)
 
119
 
 
120
# Branch prediction
 
121
if env['BRANCH'] == 'profile':
 
122
        env.Append(CCFLAGS = '-fprofile-arcs')
 
123
        env.Append(LINKFLAGS = '-fprofile-arcs')
 
124
elif env['BRANCH'] == 'seed':
 
125
        env.Append(CCFLAGS = '-fbranch-probabilities')
 
126
 
 
127
# Coverage analysis
 
128
if env['COVERAGE'] == 'full':
 
129
        env.Append(CCFLAGS = '-fprofile-arcs')
 
130
        env.Append(CCFLAGS = '-ftest-coverage')
 
131
        env.Append(LINKFLAGS = '-fprofile-arcs')
 
132
        env.Append(LINKFLAGS = '-lgcov')
 
133
 
 
134
# Define separate build environments
 
135
release = env.Clone(BUILD = 'release')
 
136
release.Append(CCFLAGS = '-O2')
 
137
 
 
138
debug = env.Clone(BUILD = 'debug')
 
139
debug.Append(CCFLAGS = '-ggdb', LINKFLAGS = '-gdb')
 
140
 
 
141
profile = env.Clone(BUILD = 'profile')
 
142
profile.Append(CCFLAGS = ['-O2','-pg'], LINKFLAGS = '-pg')
 
143
 
 
144
thirtytwo = release.Clone(BUILD = 'thirtytwo')
 
145
thirtytwo.Append(CCFLAGS = '-m32', LINKFLAGS = '-m32')
 
146
 
 
147
# choose and environment to build
 
148
if env['BUILD'] == 'release':
 
149
        Export({'env':release})
 
150
elif env['BUILD'] == 'profile':
 
151
        Export({'env':profile})
 
152
elif env['BUILD'] == 'thirtytwo':
 
153
        Export({'env':thirtytwo})
 
154
else:
 
155
        Export({'env':debug})
 
156
 
 
157
#-----------------------------------------------------------------------------
 
158
# Re-analyse dependencies
 
159
 
 
160
Import('env')
 
161
 
 
162
# vanilla environment
 
163
env.ParseConfig('pkg-config --cflags --libs glib-2.0 gthread-2.0');
 
164
 
 
165
# instrumentation
 
166
if env['WITH_HTTP'] == 'true' and env['WITH_HISTOGRAMS'] == 'true':
 
167
        env.Append(CCFLAGS = '-DCONFIG_HISTOGRAMS');
 
168
 
 
169
# managed environment for libpgmsnmp, libpgmhttp
 
170
env['SNMP_FLAGS'] = { 
 
171
        'CCFLAGS'       : [],
 
172
        'LIBS'          : [ 'netsnmpagent', 'netsnmpmibs', 'netsnmphelpers', 'netsnmp' ],
 
173
};
 
174
 
 
175
def CheckSNMP(context):
 
176
        context.Message('Checking Net-SNMP...');
 
177
        lastLIBS = context.env['LIBS'];
 
178
        lastCCFLAGS= context.env['CCFLAGS'];
 
179
        context.env.MergeFlags(env['SNMP_FLAGS']);
 
180
        result = context.TryLink("""
 
181
int main(int argc, char**argv)
 
182
{
 
183
        init_agent("PGM");
 
184
        return 0;
 
185
}
 
186
""", '.c');
 
187
        context.env.Replace(LIBS = lastLIBS, CCFLAGS=lastCCFLAGS);
 
188
        context.Result(not result);
 
189
        return result;
 
190
 
 
191
def CheckCheck(context):
 
192
        context.Message('Checking Check unit test framework...');
 
193
        result = context.TryAction('pkg-config --cflags --libs check')[0];
 
194
        context.Result(result);
 
195
        return result;
 
196
 
 
197
def CheckEventFD(context):
 
198
        context.Message('Checking eventfd...');
 
199
        result = context.TryLink("""
 
200
#include <sys/eventfd.h>
 
201
int main(int argc, char**argv)
 
202
{
 
203
        eventfd(0,0);
 
204
        return 0;
 
205
}
 
206
""", '.c')
 
207
        context.Result(result);
 
208
        return result;
 
209
 
 
210
tests = {
 
211
        'CheckCheck':   CheckCheck,
 
212
        'CheckEventFD': CheckEventFD
 
213
}
 
214
if env['WITH_SNMP'] == 'true':
 
215
        tests['CheckSNMP'] = CheckSNMP;
 
216
conf = Configure(env, custom_tests = tests);
 
217
 
 
218
if env['WITH_SNMP'] == 'true' and not conf.CheckSNMP():
 
219
        print 'Enabling extra Red Hat dependencies for Net-SNMP.';
 
220
        conf.env['SNMP_FLAGS']['LIBS'].append(['librpm', 'libsensors', 'libdl', 'libwrap']);
 
221
        lastLIBS = conf.env['LIBS'];
 
222
        conf.env.ParseConfig('perl -MExtUtils::Embed -e ldopts');
 
223
        conf.env['SNMP_FLAGS']['LIBS'].append(conf.env['LIBS']);
 
224
        conf.env.Replace(LIBS = lastLIBS);
 
225
        if not conf.CheckSNMP():
 
226
                print 'Net-SNMP libraries not compatible.';
 
227
                Exit(1);
 
228
 
 
229
if env['WITH_CHECK'] == 'true' and conf.CheckCheck():
 
230
        print 'Enabling Check unit tests.';
 
231
        conf.env['CHECK'] = 'true';
 
232
        env['CHECK_FLAGS'] = env.ParseFlags('!pkg-config --cflags --libs check');
 
233
else:
 
234
        print 'Disabling Check unit tests.';
 
235
        conf.env['CHECK'] = 'false';
 
236
 
 
237
if conf.CheckEventFD():
 
238
        print 'Enabling kernel eventfd notification mechanism.';
 
239
        conf.env.Append(CCFLAGS = '-DCONFIG_EVENTFD');
 
240
 
 
241
env = conf.Finish();
 
242
 
 
243
# DSO visibility flags
 
244
if '-DCONFIG_HAVE_DSO_VISIBILITY' in env['CCFLAGS']:
 
245
        env.Append(CCFLAGS = '-DPGM_GNUC_INTERNAL=G_GNUC_INTERNAL')
 
246
else:
 
247
        env.Append(CCFLAGS = '-DPGM_GNUC_INTERNAL=')
 
248
 
 
249
# add builder to create PIC static libraries for including in shared libraries
 
250
action_list = [ Action("$ARCOM", "$ARCOMSTR") ];
 
251
if env.Detect('ranlib'):
 
252
        ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR");
 
253
        action_list.append(ranlib_action);
 
254
pic_lib = Builder(      action = action_list,
 
255
                        emitter = '$LIBEMITTER',
 
256
                        prefix = '$LIBPREFIX',
 
257
                        suffix = '$LIBSUFFIX',
 
258
                        src_suffix = '$OBJSUFFIX',
 
259
                        src_builder = 'SharedObject')
 
260
env.Append(BUILDERS = {'StaticSharedLibrary': pic_lib});
 
261
 
 
262
 
 
263
#-----------------------------------------------------------------------------
 
264
 
 
265
ref_node = 'ref/' + env['BUILD'] + '/';
 
266
BuildDir(ref_node, '.', duplicate=0)
 
267
 
 
268
env.Append(CPPPATH = os.getcwd() + '/include');
 
269
env.Append(LIBPATH = os.getcwd() + '/' + ref_node);
 
270
 
 
271
SConscript(ref_node + 'SConscript.libpgm');
 
272
SConscript(ref_node + 'SConscript.libpgmex');
 
273
if env['WITH_HTTP'] == 'true':
 
274
        SConscript(ref_node + 'SConscript.libpgmhttp');
 
275
if env['WITH_SNMP'] == 'true':
 
276
        SConscript(ref_node + 'SConscript.libpgmsnmp');
 
277
if env['WITH_TEST'] == 'true':
 
278
        SConscript(ref_node + 'test/SConscript');
 
279
if env['WITH_EXAMPLES'] == 'true':
 
280
        SConscript(ref_node + 'examples/SConscript');
 
281
 
 
282
# end of file