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