Detect the pthread.h header file and automatically disable components that cannot build without it.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Mon, 08 Sep 2008 12:19:46 +0100
changeset 3648f912b24ddf2d
parent 3647 cd704871a4ed
child 3649 c1a2ee633ab5
Detect the pthread.h header file and automatically disable components that cannot build without it.
bindings/python/ns3modulegen.py
src/core/wscript
src/simulator/event-impl.h
src/simulator/wscript
     1.1 --- a/bindings/python/ns3modulegen.py	Mon Sep 08 11:20:17 2008 +0100
     1.2 +++ b/bindings/python/ns3modulegen.py	Mon Sep 08 12:19:46 2008 +0100
     1.3 @@ -126,6 +126,15 @@
     1.4          except KeyError:
     1.5              pass
     1.6  
     1.7 +    if 'Threading' not in enabled_features:
     1.8 +        for clsname in ['SystemThread', 'SystemMutex', 'SystemCondition', 'CriticalSection']:
     1.9 +            root_module.classes.remove(root_module['ns3::%s' % clsname])
    1.10 +
    1.11 +    if 'RealTime' not in enabled_features:
    1.12 +        for clsname in ['WallClockSynchronizer', 'RealtimeSimulatorImpl', 'RealtimeEventLock']:
    1.13 +            root_module.classes.remove(root_module['ns3::%s' % clsname])
    1.14 +        root_module.enums.remove(root_module['ns3::RealtimeSimulatorImpl::SynchronizationMode'])
    1.15 +
    1.16      root_module.generate(out, '_ns3')
    1.17  
    1.18      out.close()
     2.1 --- a/src/core/wscript	Mon Sep 08 11:20:17 2008 +0100
     2.2 +++ b/src/core/wscript	Mon Sep 08 12:19:46 2008 +0100
     2.3 @@ -28,6 +28,15 @@
     2.4      e.uselib = 'RT'
     2.5      e.run()
     2.6  
     2.7 +    e = conf.create_header_configurator()
     2.8 +    e.mandatory = False
     2.9 +    e.name = 'pthread.h'
    2.10 +    e.define = 'HAVE_PTHREAD_H'
    2.11 +    conf.env['ENABLE_THREADING'] = e.run()
    2.12 +    conf.report_optional_feature("Threading", "Threading Primitives",
    2.13 +                                 conf.env['ENABLE_THREADING'],
    2.14 +                                 "<pthread.h> include not detected")
    2.15 +
    2.16      conf.write_config_header('ns3/core-config.h')
    2.17  
    2.18  def build(bld):
    2.19 @@ -66,24 +75,9 @@
    2.20          ]
    2.21      core.uselib = 'RT'
    2.22  
    2.23 -    if sys.platform == 'win32':
    2.24 -        core.source.extend([
    2.25 -            'win32-system-wall-clock-ms.cc',
    2.26 -            ])
    2.27 -    else:
    2.28 -        core.source.extend([
    2.29 -            'unix-system-thread.cc',
    2.30 -            'unix-system-mutex.cc',
    2.31 -            'unix-system-condition.cc',
    2.32 -            'unix-system-wall-clock-ms.cc',
    2.33 -            ])
    2.34 -    
    2.35      headers = bld.create_obj('ns3header')
    2.36      headers.module = 'core'
    2.37      headers.source = [
    2.38 -        'system-mutex.h',
    2.39 -        'system-thread.h',
    2.40 -        'system-condition.h',
    2.41          'system-wall-clock-ms.h',
    2.42          'empty.h',
    2.43          'callback.h',
    2.44 @@ -124,3 +118,24 @@
    2.45          'deprecated.h'
    2.46          ]
    2.47  
    2.48 +    if sys.platform == 'win32':
    2.49 +        core.source.extend([
    2.50 +            'win32-system-wall-clock-ms.cc',
    2.51 +            ])
    2.52 +    else:
    2.53 +        core.source.extend([
    2.54 +            'unix-system-wall-clock-ms.cc',
    2.55 +            ])
    2.56 +
    2.57 +    if bld.env()['ENABLE_THREADING']:
    2.58 +        core.source.extend([
    2.59 +            'unix-system-thread.cc',
    2.60 +            'unix-system-mutex.cc',
    2.61 +            'unix-system-condition.cc',
    2.62 +            ])
    2.63 +        headers.source.extend([
    2.64 +                'system-mutex.h',
    2.65 +                'system-thread.h',
    2.66 +                'system-condition.h',
    2.67 +                ])
    2.68 +
     3.1 --- a/src/simulator/event-impl.h	Mon Sep 08 11:20:17 2008 +0100
     3.2 +++ b/src/simulator/event-impl.h	Mon Sep 08 12:19:46 2008 +0100
     3.3 @@ -21,7 +21,6 @@
     3.4  #define EVENT_IMPL_H
     3.5  
     3.6  #include <stdint.h>
     3.7 -#include "ns3/system-mutex.h"
     3.8  
     3.9  namespace ns3 {
    3.10  
     4.1 --- a/src/simulator/wscript	Mon Sep 08 11:20:17 2008 +0100
     4.2 +++ b/src/simulator/wscript	Mon Sep 08 12:19:46 2008 +0100
     4.3 @@ -44,6 +44,9 @@
     4.4  
     4.5      conf.write_config_header('ns3/simulator-config.h')
     4.6  
     4.7 +    conf.report_optional_feature("RealTime", "Real Time Simulator",
     4.8 +                                 conf.env['ENABLE_THREADING'],
     4.9 +                                 "threading not enabled")
    4.10  
    4.11  
    4.12  def build(bld):
    4.13 @@ -59,11 +62,9 @@
    4.14          'event-impl.cc',
    4.15          'simulator.cc',
    4.16          'default-simulator-impl.cc',
    4.17 -        'realtime-simulator-impl.cc',
    4.18          'timer.cc',
    4.19          'watchdog.cc',
    4.20          'synchronizer.cc',
    4.21 -        'wall-clock-synchronizer.cc',
    4.22          ]
    4.23  
    4.24      headers = bld.create_obj('ns3header')
    4.25 @@ -76,7 +77,6 @@
    4.26          'simulator.h',
    4.27          'simulator-impl.h',
    4.28          'default-simulator-impl.h',
    4.29 -        'realtime-simulator-impl.h',
    4.30          'scheduler.h',
    4.31          'list-scheduler.h',
    4.32          'map-scheduler.h',
    4.33 @@ -86,7 +86,6 @@
    4.34          'timer-impl.h',
    4.35          'watchdog.h',
    4.36          'synchronizer.h',
    4.37 -        'wall-clock-synchronizer.h',
    4.38          ]
    4.39  
    4.40      env = bld.env_of_name('default')
    4.41 @@ -107,3 +106,13 @@
    4.42              'cairo-wideint-private.h',
    4.43              ])
    4.44  
    4.45 +    if env['ENABLE_THREADING']:
    4.46 +        headers.source.extend([
    4.47 +                'realtime-simulator-impl.h',
    4.48 +                'wall-clock-synchronizer.h',
    4.49 +                ])
    4.50 +        sim.source.extend([
    4.51 +                'realtime-simulator-impl.cc',
    4.52 +                'wall-clock-synchronizer.cc',
    4.53 +                ])
    4.54 +