## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- import sys import Options def set_options(opt): opt.add_option('--high-precision-as-double', help=('Whether to use a double floating point' ' type for high precision time values' ' WARNING: this option only has effect ' 'with the configure command.'), action="store_true", default=False, dest='high_precision_as_double') def configure(conf): if conf.check(header_name='stdlib.h'): conf.define('HAVE_STDLIB_H', 1) conf.define('HAVE_GETENV', 1) conf.check(header_name='signal.h', define_name='HAVE_SIGNAL_H') # Check for POSIX threads test_env = conf.env.copy() if Options.platform != 'darwin' and Options.platform != 'cygwin': test_env.append_value('LINKFLAGS', '-pthread') test_env.append_value('CXXFLAGS', '-pthread') test_env.append_value('CCFLAGS', '-pthread') fragment = r""" #include int main () { pthread_mutex_t m; pthread_mutex_init (&m, NULL); return 0; } """ have_pthread = conf.check(header_name='pthread.h', define_name='HAVE_PTHREAD_H', env=test_env, fragment=fragment, errmsg='Could not find pthread support (build/config.log for details)', mandatory=False) if have_pthread: # darwin accepts -pthread but prints a warning saying it is ignored if Options.platform != 'darwin' and Options.platform != 'cygwin': conf.env['CXXFLAGS_PTHREAD'] = '-pthread' conf.env['CCFLAGS_PTHREAD'] = '-pthread' conf.env['LINKFLAGS_PTHREAD'] = '-pthread' conf.env['ENABLE_THREADING'] = have_pthread conf.report_optional_feature("Threading", "Threading Primitives", conf.env['ENABLE_THREADING'], " include not detected") a = conf.check(type_name='uint128_t', define_name='HAVE_UINT128_T') b = conf.check(type_name='__uint128_t', define_name='HAVE___UINT128_T') if Options.options.high_precision_as_double: conf.define('USE_HIGH_PRECISION_DOUBLE', 1) conf.env['USE_HIGH_PRECISION_DOUBLE'] = 1 highprec = 'long double' elif a or b: conf.define('USE_HIGH_PRECISION_128', 1) conf.env['USE_HIGH_PRECISION_128'] = 1 highprec = '128-bit integer' else: conf.define('USE_HIGH_PRECISION_CAIRO', 1) conf.env['USE_HIGH_PRECISION_CAIRO'] = 1 highprec = 'cairo 128-bit integer' conf.check_message_custom('high precision time', 'implementation', highprec) conf.check(header_name='stdint.h', define_name='HAVE_STDINT_H') conf.check(header_name='inttypes.h', define_name='HAVE_INTTYPES_H') conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H') if not conf.check(lib='rt', uselib='RT', define_name='HAVE_RT'): conf.report_optional_feature("RealTime", "Real Time Simulator", False, "librt is not available") else: conf.report_optional_feature("RealTime", "Real Time Simulator", conf.env['ENABLE_THREADING'], "threading not enabled") conf.env["ENABLE_REAL_TIME"] = conf.env['ENABLE_THREADING'] conf.write_config_header('ns3/core-config.h', top=True) def build(bld): core = bld.create_ns3_module('core') core.source = [ 'model/high-precision.cc', 'model/time-base.cc', 'model/time.cc', 'model/event-id.cc', 'model/scheduler.cc', 'model/list-scheduler.cc', 'model/map-scheduler.cc', 'model/heap-scheduler.cc', 'model/calendar-scheduler.cc', 'model/ns2-calendar-scheduler.cc', 'model/event-impl.cc', 'model/simulator.cc', 'model/simulator-impl.cc', 'model/default-simulator-impl.cc', 'model/timer.cc', 'model/watchdog.cc', 'model/synchronizer.cc', 'model/make-event.cc', 'model/log.cc', 'model/breakpoint.cc', 'model/type-id.cc', 'model/attribute-list.cc', 'model/object-base.cc', 'model/ref-count-base.cc', 'model/object.cc', 'model/test.cc', 'model/random-variable.cc', 'model/rng-stream.cc', 'model/command-line.cc', 'model/type-name.cc', 'model/attribute.cc', 'model/boolean.cc', 'model/integer.cc', 'model/uinteger.cc', 'model/enum.cc', 'model/double.cc', 'model/string.cc', 'model/pointer.cc', 'model/object-vector.cc', 'model/object-factory.cc', 'model/global-value.cc', 'model/trace-source-accessor.cc', 'model/config.cc', 'model/callback.cc', 'model/names.cc', 'model/vector.cc', 'model/fatal-impl.cc', 'test/attribute-test-suite.cc', 'test/callback-test-suite.cc', 'test/names-test-suite.cc', 'test/type-traits-test-suite.cc', 'test/traced-callback-test-suite.cc', 'test/ptr-test-suite.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'core' headers.source = [ 'model/high-precision.h', 'model/time-base.h', 'model/nstime.h', 'model/event-id.h', 'model/event-impl.h', 'model/simulator.h', 'model/simulator-impl.h', 'model/default-simulator-impl.h', 'model/scheduler.h', 'model/list-scheduler.h', 'model/map-scheduler.h', 'model/heap-scheduler.h', 'model/calendar-scheduler.h', 'model/ns2-calendar-scheduler.h', 'model/simulation-singleton.h', 'model/timer.h', 'model/timer-impl.h', 'model/watchdog.h', 'model/synchronizer.h', 'model/make-event.h', 'model/system-wall-clock-ms.h', 'model/empty.h', 'model/callback.h', 'model/object-base.h', 'model/ref-count-base.h', 'model/simple-ref-count.h', 'model/type-id.h', 'model/attribute-list.h', 'model/ptr.h', 'model/object.h', 'model/log.h', 'model/assert.h', 'model/breakpoint.h', 'model/fatal-error.h', 'model/test.h', 'model/random-variable.h', 'model/rng-stream.h', 'model/command-line.h', 'model/type-name.h', 'model/type-traits.h', 'model/int-to-type.h', 'model/attribute.h', 'model/attribute-accessor-helper.h', 'model/boolean.h', 'model/integer.h', 'model/uinteger.h', 'model/double.h', 'model/enum.h', 'model/string.h', 'model/pointer.h', 'model/object-factory.h', 'model/attribute-helper.h', 'model/global-value.h', 'model/traced-callback.h', 'model/traced-value.h', 'model/trace-source-accessor.h', 'model/config.h', 'model/object-vector.h', 'model/deprecated.h', 'model/abort.h', 'model/names.h', 'model/vector.h', 'model/default-deleter.h', 'model/fatal-impl.h', ] if sys.platform == 'win32': core.source.extend([ 'model/win32-system-wall-clock-ms.cc', ]) else: core.source.extend([ 'model/unix-system-wall-clock-ms.cc', ]) env = bld.env_of_name('default') if env['USE_HIGH_PRECISION_DOUBLE']: headers.source.extend(['model/high-precision-double.h']) elif env['USE_HIGH_PRECISION_128']: headers.source.extend(['model/high-precision-128.h']) core.source.extend(['model/high-precision-128.cc']) elif env['USE_HIGH_PRECISION_CAIRO']: core.source.extend([ 'model/high-precision-cairo.cc', # 'model/cairo-wideint.c', ]) headers.source.extend([ 'model/high-precision-cairo.h', 'model/cairo-wideint-private.h', ]) if env['ENABLE_REAL_TIME']: headers.source.extend([ 'model/realtime-simulator-impl.h', 'model/wall-clock-synchronizer.h', ]) core.source.extend([ 'model/realtime-simulator-impl.cc', 'model/wall-clock-synchronizer.cc', ]) core.uselib = 'RT' else: core.uselib = '' if env['ENABLE_THREADING']: core.source.extend([ 'model/unix-fd-reader.cc', 'model/unix-system-thread.cc', 'model/unix-system-mutex.cc', 'model/unix-system-condition.cc', ]) core.uselib = core.uselib + ' PTHREAD' headers.source.extend([ 'model/unix-fd-reader.h', 'model/system-mutex.h', 'model/system-thread.h', 'model/system-condition.h', ]) if env['ENABLE_GSL']: core.uselib = core.uselib + ' GSL GSLCBLAS M' core.source.extend(['test/rng-test-suite.cc']) bld.ns3_python_bindings()