SetOption('num_jobs', 8)

AddOption('--prefix',
          dest='prefix',
          type='string',
          nargs=1,
          action='store',
          metavar='DIR',
          help='installation prefix')

#PYTHON_LIB_DIR = '/usr/local/Frameworks/Python.framework/Versions/Current/lib/python2.7'
PYTHON_LIB_DIR = '/Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/lib/python2.7'

#PYTHON_INCLUDE_DIR = '/usr/local/Frameworks/Python.framework/Versions/Current/lib/python2.7'
PYTHON_INCLUDE_DIR = '/Applications/Canopy.app/appdata/canopy-1.0.3.1262.macosx-x86_64/Canopy.app/Contents/include/python2.7'

libpath=['.', '/usr/local/lib',
         PYTHON_LIB_DIR + '/config',
         PYTHON_LIB_DIR]
libs=['boost_python-mt', 'python2.7']

#PYTHON_SITE_PACKAGES_DIR = '/usr/local/lib/python2.7/site-packages' 
PYTHON_SITE_PACKAGES_DIR = '/Users/fogelson/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages'

includepath=[PYTHON_SITE_PACKAGES_DIR + '/numpy/core/include',
             PYTHON_INCLUDE_DIR,
             '/usr/local/include']

cxxflags=['-w','-O2','-fopenmp']

linkflags=['-fopenmp']

VariantDir('build','src')

prefix = GetOption('prefix')

if prefix == None:
    #prefix = '/usr/local/lib/python2.7/site-packages'
    prefix = '/Users/fogelson/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages'

installdir = prefix + '/stokeslet'

bindir = '/usr/local/Cellar/stokeslet/0.1/bin'

env = Environment()

env.Replace(CC = "gcc-4.5")#-4.5")
env.Replace(CXX = "g++-4.5")#-4.5")

env.Append(CPPPATH = includepath)
env.Append(LIBPATH = libpath)
env.Append(LIBS = libs)
env.Append(CXXFLAGS = cxxflags)
env.Append(LINKFLAGS = linkflags)

env.Replace(SHLIBSUFFIX = '.so')

module_dir = 'build/core_module/'
script_dir = 'build/scripts/'

def append_module_dir(s):
    return module_dir + s

def append_script_dir(s):
    return script_dir + s

core_module_sources = ['compute_flow.cpp',
           'compute_mobility.cpp',
           'set_rhs_for_mobility.cpp',
           'stokeslet_main.cpp']

core_module_python = ['__init__.py',
                      'common.py',
                      'stokeslet.py',
                      'stokesletsetup.py',
                      'pointforces.py',
                      'fluidgrid.py',
                      'generate.py',
                      'compute.py',
                      'graphics.py',
                      'batchconfig.py',
                      'cellshape.py',
                      'units.py']

script_python = ['run_batch.py']

core_module_sources = map(append_module_dir, core_module_sources)
core_module_python = map(append_module_dir, core_module_python)

script_python = map(append_script_dir, script_python)

stokeslet_cpp = env.SharedLibrary('stokeslet_cpp',core_module_sources)
python_files = File(core_module_python)
script_files = File(script_python)

env.Install(installdir, stokeslet_cpp)
env.Install(installdir, python_files)
env.Alias('install',installdir)

Clean('.','build')
Clean('install','build')
Clean('install',installdir)
