wscript
changeset 64 015a353a487b
parent 63 e89dca438df6
child 65 227f6347e4e1
     1.1 --- a/wscript	Mon Apr 18 12:13:02 2011 +0200
     1.2 +++ b/wscript	Tue Apr 19 14:49:49 2011 +0200
     1.3 @@ -1,90 +1,29 @@
     1.4  ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
     1.5  
     1.6  import os
     1.7 -
     1.8  import Options
     1.9  import os.path
    1.10 +import ns3waf
    1.11  
    1.12 -class CouldNotFindFile:
    1.13 -    pass
    1.14 -
    1.15 -def search_file(files):
    1.16 -    for f in files:
    1.17 -        if os.path.isfile (f):
    1.18 -            return f
    1.19 -    raise CouldNotFindFile ()
    1.20 -
    1.21 -
    1.22 -
    1.23 -
    1.24 -def create_dce_program(bld, name, is_c_only = False):
    1.25 -    if not is_c_only:
    1.26 -        program = bld.new_task_gen('cxx', 'program')
    1.27 -        var = 'CXXFLAGS'
    1.28 -    else:
    1.29 -        program = bld.new_task_gen('cc', 'program')
    1.30 -        var = 'CCFLAGS'
    1.31 -    program.env.append_value(var, '-fpie')
    1.32 -    program.env.append_value(var, '-U_FORTIFY_SOURCE')
    1.33 -    if os.uname()[4] == 'x86_64':
    1.34 -        program.env.append_value(var, '-mcmodel=large')
    1.35 -#    program.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=/usr/lib/debug/ld-linux-x86-64.so.2')
    1.36 -    program.is_ns3_program = True
    1.37 -    program.name = name
    1.38 -    program.target = name
    1.39 -    program.env.append_value('LINKFLAGS', '-pie')
    1.40 -    return program
    1.41 -
    1.42 -def add_build_dir(conf,d):
    1.43 -    build_dir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant(), 'src', 'dce', d))
    1.44 -    conf.env.append_value('NS3_MODULE_PATH', build_dir)
    1.45 -
    1.46 -
    1.47 -def set_options(opt):
    1.48 +def options(opt):
    1.49      opt.tool_options('compiler_cc') 
    1.50 -    opt.add_option('--with-linux-stack',
    1.51 -                   help=('Path to the linux module'),
    1.52 -                   default=None,
    1.53 -                   dest='linux_stack', type="string")
    1.54 +    ns3waf.options(opt)
    1.55  
    1.56  def configure(conf):
    1.57 -    add_build_dir(conf, 'model')
    1.58 -    add_build_dir(conf, 'vdl')
    1.59 -    add_build_dir(conf, 'test')
    1.60 -    add_build_dir(conf, 'example')
    1.61 +    ns3waf.check_modules(conf, ['core', 'network', 'internet'], mandatory = True)
    1.62  
    1.63      conf.check_tool('compiler_cc')
    1.64 -    conf.check(function_name='makecontext', 
    1.65 -               header_name='ucontext.h',
    1.66 -               mandatory=True)
    1.67 +
    1.68      conf.env.append_value('LINKFLAGS', '-pthread')
    1.69      conf.env['HAVE_DL'] = conf.check (lib='dl')
    1.70  
    1.71 -    if Options.options.linux_stack is not None and os.path.isdir(Options.options.linux_stack):
    1.72 -        conf.check_message("linux stack location", '', True, 
    1.73 -                           ("%s (given)" % Options.options.linux_stack))
    1.74 -        conf.report_optional_feature("linux stack", "Linux stack", True,
    1.75 -                                     "enabled (found in %s)" % Options.options.linux_stack)
    1.76 -        conf.env['LINUX_STACK'] = os.path.abspath(Options.options.linux_stack)
    1.77 -        conf.env.append_value('NS3_MODULE_PATH', conf.env['LINUX_STACK'])
    1.78 -    else:
    1.79 -        conf.check_message("linux stack location", '', False)
    1.80 -        conf.report_optional_feature("linux stack", "Linux stack", False,
    1.81 -                                     "linux stack not found")
    1.82 -
    1.83 -    vg_h = conf.check(header_name='valgrind/valgrind.h')
    1.84 -    vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h')
    1.85 +    vg_h = conf.check(header_name='valgrind/valgrind.h', mandatory=False)
    1.86 +    vg_memcheck_h = conf.check(header_name='valgrind/memcheck.h', mandatory=False)
    1.87      if vg_h and vg_memcheck_h:
    1.88          conf.env.append_value('CXXDEFINES', 'HAVE_VALGRIND_H')
    1.89  
    1.90 -    conf.sub_config('vdl')
    1.91 -
    1.92  def build(bld):
    1.93 -    import types
    1.94 -    bld.create_dce_program = types.MethodType(create_dce_program, bld)
    1.95 -    # beeeurk: most deps below are un-needed.
    1.96 -    dce = bld.create_ns3_module('dce', ['core', 'network', 'internet', 'point-to-point'])
    1.97 -    dce.source = [
    1.98 +    module_source = [
    1.99          'model/dce-manager.cc',
   1.100  	'model/dce-application.cc',
   1.101          'model/dce.cc',
   1.102 @@ -141,11 +80,7 @@
   1.103          'helper/dce-manager-helper.cc',
   1.104          'helper/dce-application-helper.cc',
   1.105          ]
   1.106 -    dce.uselib = 'DL'
   1.107 -
   1.108 -    headers = bld.new_task_gen('ns3header')
   1.109 -    headers.module = 'dce'
   1.110 -    headers.source = [
   1.111 +    module_headers = [
   1.112          'model/dce-manager.h',
   1.113          'model/task-scheduler.h',
   1.114          'model/task-manager.h',
   1.115 @@ -160,86 +95,12 @@
   1.116          'model/netlink-attribute.h',
   1.117          'model/netlink-socket-address.h',
   1.118          ]
   1.119 -
   1.120 -    if dce.env['LINUX_STACK']:
   1.121 -        dce.source.extend([
   1.122 -                'model/linux-socket-fd-factory.cc',
   1.123 -                'model/linux-socket-fd.cc',
   1.124 -                ])
   1.125 -        dce.includes = dce.env['LINUX_STACK']
   1.126 -        headers.source.extend ([
   1.127 -                'model/linux-socket-fd-factory.h'])
   1.128 -
   1.129 -
   1.130 -    rvd = bld.new_task_gen('cc', 'program')
   1.131 -    rvd.name = 'readversiondef'
   1.132 -    rvd.target = 'readversiondef'
   1.133 -    rvd.source = ['model/readversiondef.c']
   1.134 -
   1.135 -    bld.add_group('dce_version_files')
   1.136 -
   1.137 -    libc = search_file ([
   1.138 -            '/lib64/libc.so.6',
   1.139 -            '/lib/libc.so.6',
   1.140 -            ])
   1.141 -    libpthread = search_file ([
   1.142 -            '/lib64/libpthread.so.0',
   1.143 -            '/lib/libpthread.so.0',
   1.144 -            ])
   1.145 -
   1.146 -    bld.new_task_gen(source=['readversiondef', 'model/libc-ns3.version'],
   1.147 -                     target='libc.version',
   1.148 -                     rule='${SRC[0].abspath(env)} ' + libc + ' |' \
   1.149 -                         'cat ${SRC[1].abspath()} - > ${TGT}')
   1.150 -
   1.151 -    bld.new_task_gen(source=['readversiondef', 'model/libpthread-ns3.version'],
   1.152 -                     target='libpthread.version',
   1.153 -                     rule='${SRC[0].abspath(env)} ' + libpthread + ' |' \
   1.154 -                         'cat ${SRC[1].abspath()} - > ${TGT}')
   1.155 -
   1.156 -    bld.add_group('dce_use_version_files')
   1.157 -
   1.158 -    # The very small libc used to replace the glibc
   1.159 -    # and forward to the dce_* code
   1.160 -    module = bld.new_task_gen('cc', 'shlib')
   1.161 -    module.name = 'c-ns3'
   1.162 -    module.target = module.name
   1.163 -    module.env.append_value('CCFLAGS', module.env['shlib_CCFLAGS'])
   1.164 -    module.env.append_value('CCFLAGS', '-g')
   1.165 -    module.env.append_value('CCDEFINES', 'LIBSETUP=libc_setup')
   1.166 -    module.env.append_value('LINKFLAGS', '-nostdlib')
   1.167 -    module.env.append_value('LINKFLAGS', 
   1.168 -                            '-Wl,--version-script=' + bld.path.find_or_declare('libc.version').bldpath(bld.env))
   1.169 -    module.env.append_value('LINKFLAGS', '-Wl,-soname=libc.so.6')
   1.170 -    module.source = ['model/libc.c', 'model/libc-global-variables.c']
   1.171 -
   1.172 -    # The very small libpthread used to replace the glibc
   1.173 -    # and forward to the dce_* code
   1.174 -    module = bld.new_task_gen('cc', 'shlib')
   1.175 -    module.name = 'pthread-ns3'
   1.176 -    module.target = module.name
   1.177 -    module.env.append_value('CCFLAGS', module.env['shlib_CCFLAGS'])
   1.178 -    module.env.append_value('CCFLAGS', '-g')
   1.179 -    module.env.append_value('CCDEFINES', 'LIBSETUP=libpthread_setup')
   1.180 -    module.env.append_value('LINKFLAGS', '-nostdlib')
   1.181 -    module.env.append_value('LINKFLAGS', '-lc')
   1.182 -    module.env.append_value('LINKFLAGS', 
   1.183 -                            '-Wl,--version-script=' + bld.path.find_or_declare('libpthread.version').bldpath(bld.env))
   1.184 -    module.env.append_value('LINKFLAGS', '-Wl,-soname=libpthread.so.0')
   1.185 -    module.source = ['model/libc.c']
   1.186 -
   1.187 -    # The following is needed to debug loader errors on ubuntu when you install libc6-dbg.
   1.188 -    #obj.env.append_value('LINKFLAGS', '-Wl,--dynamic-linker=/usr/lib/debug/ld-linux.so.2')
   1.189 -
   1.190 -    bld.set_group(0)
   1.191 -
   1.192 -    dce_test = bld.create_ns3_module_test_library('dce')
   1.193 -    dce_test.source = [
   1.194 +    module_test = [
   1.195          'test/dce-manager-test.cc',
   1.196          'test/netlink-socket-test.cc',
   1.197          ]
   1.198 -
   1.199 -    if (bld.env['ENABLE_EXAMPLES']):
   1.200 -        bld.add_subdirs(['example'])
   1.201 -
   1.202 -    bld.add_subdirs(['vdl', 'test', 'utils'])
   1.203 +    uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet'])
   1.204 +    ns3waf.build_module(bld, 'dce',
   1.205 +                        source=module_source,
   1.206 +                        headers=module_headers,
   1.207 +                        use=uselib)