src/core/wscript
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 04 Jul 2009 08:15:48 +0200
changeset 4654 2eaebe77d66b
parent 4368 fc00cd53d37b
permissions -rw-r--r--
Added tag ns-3.5 for changeset c975274c9707
     1 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
     2 import sys
     3 import Options
     4 
     5 def configure(conf):
     6     if conf.check(header_name='stdlib.h'):
     7         conf.define('HAVE_STDLIB_H', 1)
     8         conf.define('HAVE_GETENV', 1)
     9 
    10     conf.check(header_name='signal.h', define_name='HAVE_SIGNAL_H')
    11 
    12     # Check for POSIX threads
    13     test_env = conf.env.copy()
    14     if Options.platform != 'darwin' and Options.platform != 'cygwin':
    15         test_env.append_value('LINKFLAGS', '-pthread')
    16         test_env.append_value('CXXFLAGS', '-pthread')
    17         test_env.append_value('CCFLAGS', '-pthread')
    18     fragment = r"""
    19 #include <pthread.h>
    20 int main ()
    21 {
    22    pthread_mutex_t m;
    23    pthread_mutex_init (&m, NULL);
    24    return 0;
    25 }
    26 """
    27     have_pthread = conf.check(header_name='pthread.h', define_name='HAVE_PTHREAD_H',
    28                               env=test_env, fragment=fragment,
    29                               errmsg='Could not find pthread support (build/config.log for details)',
    30                               mandatory=False)
    31     if have_pthread:
    32         # darwin accepts -pthread but prints a warning saying it is ignored
    33         if Options.platform != 'darwin' and Options.platform != 'cygwin':
    34             conf.env['CXXFLAGS_PTHREAD'] = '-pthread'
    35             conf.env['CCFLAGS_PTHREAD'] = '-pthread'
    36             conf.env['LINKFLAGS_PTHREAD'] = '-pthread'
    37 
    38     conf.env['ENABLE_THREADING'] = have_pthread
    39 
    40     conf.report_optional_feature("Threading", "Threading Primitives",
    41                                  conf.env['ENABLE_THREADING'],
    42                                  "<pthread.h> include not detected")
    43 
    44     conf.write_config_header('ns3/core-config.h', top=True)
    45 
    46 def build(bld):
    47     core = bld.create_ns3_module('core')
    48     core.source = [
    49         'callback-test.cc',
    50         'log.cc',
    51         'breakpoint.cc',
    52         'type-id.cc',
    53         'attribute-list.cc',
    54         'object-base.cc',
    55         'ref-count-base.cc',
    56         'ptr.cc',
    57         'object.cc',
    58         'test.cc',
    59         'random-variable.cc',
    60         'rng-stream.cc',
    61         'command-line.cc',
    62         'type-name.cc',
    63         'type-traits-test.cc',
    64         'attribute.cc',
    65         'boolean.cc',
    66         'integer.cc',
    67         'uinteger.cc',
    68         'enum.cc',
    69         'double.cc',
    70         'string.cc',
    71         'pointer.cc',
    72         'object-vector.cc',
    73         'attribute-test.cc',
    74         'object-factory.cc',
    75         'global-value.cc',
    76         'traced-callback.cc',
    77         'trace-source-accessor.cc',
    78         'config.cc',
    79         'callback.cc',
    80         'names.cc',
    81         ]
    82 
    83     headers = bld.new_task_gen('ns3header')
    84     headers.module = 'core'
    85     headers.source = [
    86         'system-wall-clock-ms.h',
    87         'empty.h',
    88         'callback.h',
    89         'object-base.h',
    90         'ref-count-base.h',
    91         'type-id.h',
    92         'attribute-list.h',
    93         'ptr.h',
    94         'object.h',
    95         'log.h',
    96         'assert.h',
    97         'breakpoint.h',
    98         'fatal-error.h',
    99         'test.h',
   100         'random-variable.h',
   101         'rng-stream.h',
   102         'command-line.h',
   103         'type-name.h',
   104         'type-traits.h',
   105         'int-to-type.h',
   106         'attribute.h',
   107         'attribute-accessor-helper.h',
   108         'boolean.h',
   109         'integer.h',
   110         'uinteger.h',
   111         'double.h',
   112         'enum.h',
   113         'string.h',
   114         'pointer.h',
   115         'object-factory.h',
   116         'attribute-helper.h',
   117         'global-value.h',
   118         'traced-callback.h',
   119         'traced-value.h',
   120         'trace-source-accessor.h',
   121         'config.h',
   122         'object-vector.h',
   123         'deprecated.h',
   124         'abort.h',
   125         'names.h',
   126         ]
   127 
   128     if sys.platform == 'win32':
   129         core.source.extend([
   130             'win32-system-wall-clock-ms.cc',
   131             ])
   132     else:
   133         core.source.extend([
   134             'unix-system-wall-clock-ms.cc',
   135             ])
   136 
   137     if bld.env['ENABLE_THREADING']:
   138         core.source.extend([
   139             'unix-system-thread.cc',
   140             'unix-system-mutex.cc',
   141             'unix-system-condition.cc',
   142             ])
   143         core.uselib = 'PTHREAD'
   144         headers.source.extend([
   145                 'system-mutex.h',
   146                 'system-thread.h',
   147                 'system-condition.h',
   148                 ])
   149