# Compile the mpipython executable containing
# the Scientific.MPI extension module

# Normally nothing needs to be changed below
import distutils
import distutils.sysconfig
import os  

cfgDict = distutils.sysconfig.get_config_vars()

# Name of the MPI compilation script.
mpicompiler = 'mpicc'
sources='mpipython.c Scientific_mpi.c'

mpicompiler = 'mpicc'
mpiinclude = '/usr/include/lam'
executable = 'mpipython'

if os.environ.has_key('USE_LAM'):
    mpicompiler = 'mpicc.lam'
    mpiinclude = '/usr/include/lam'
    executable = 'mpipython.lam'
if os.environ.has_key('USE_MPICH'):
    mpicompiler = 'mpicc.mpich'
    mpiinclude = '/usr/lib/mpich/include'
    executable = 'mpipython.mpich'

cmd = '%s %s -o %s -I../../Include -I%s -I%s %s -L%s -lpython%s %s %s' % \
    (mpicompiler, 
    cfgDict['LINKFORSHARED'],
    executable,
    mpiinclude,
    cfgDict['INCLUDEPY'],
    sources,
    cfgDict['LIBPL'],
    cfgDict['VERSION'], 
    cfgDict['LIBS'], 
    cfgDict['LIBM'])

print 'cmd = ', cmd 
os.system(cmd)
