58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
|
import sys
|
|
import subprocess
|
|
import Options
|
|
from waflib.Errors import WafError
|
|
|
|
def configure(conf):
|
|
env = conf.env
|
|
try:
|
|
conf.find_program('mpic++', var='MPI')
|
|
except WafError:
|
|
return
|
|
if Options.options.enable_mpi and conf.env['MPI']:
|
|
p = subprocess.Popen([conf.env['MPI'], '-showme:compile'], stdout=subprocess.PIPE)
|
|
flags = p.stdout.read().rstrip().split()
|
|
p.wait()
|
|
env.append_value("CXXFLAGS_MPI", flags)
|
|
|
|
p = subprocess.Popen([conf.env['MPI'], '-showme:link'], stdout=subprocess.PIPE)
|
|
flags = p.stdout.read().rstrip().split()
|
|
p.wait()
|
|
env.append_value("LINKFLAGS_MPI", flags)
|
|
|
|
env.append_value('CXXDEFINES', 'NS3_MPI')
|
|
conf.report_optional_feature("mpi", "MPI Support", True, '')
|
|
conf.env['ENABLE_MPI'] = True
|
|
else:
|
|
if Options.options.enable_mpi:
|
|
conf.report_optional_feature("mpi", "MPI Support", False, 'mpic++ not found')
|
|
else:
|
|
conf.report_optional_feature("mpi", "MPI Support", False, 'option --enable-mpi not selected')
|
|
|
|
|
|
def build(bld):
|
|
env = bld.env
|
|
sim = bld.create_ns3_module('mpi', ['core', 'network'])
|
|
sim.source = [
|
|
'model/distributed-simulator-impl.cc',
|
|
'model/mpi-interface.cc',
|
|
'model/mpi-receiver.cc',
|
|
]
|
|
|
|
headers = bld.new_task_gen(features=['ns3header'])
|
|
headers.module = 'mpi'
|
|
headers.source = [
|
|
'model/distributed-simulator-impl.h',
|
|
'model/mpi-interface.h',
|
|
'model/mpi-receiver.h',
|
|
]
|
|
|
|
if env['ENABLE_MPI']:
|
|
sim.use.append('MPI')
|
|
|
|
if bld.env['ENABLE_EXAMPLES']:
|
|
bld.add_subdirs('examples')
|
|
|
|
bld.ns3_python_bindings()
|