#Main Sconscript for the ---spotfinder--- module

import libtbx.load_env
import os
Import("env_base", "env_etc")

env_etc.spotfinder_dist = libtbx.env.dist_path("spotfinder")

parent_src = env_etc.norm_join(env_etc.spotfinder_dist,"..")
env_etc.spotfinder_common_includes = [
  env_etc.libtbx_include,
  env_etc.scitbx_include,
  env_etc.iotbx_include,
  os.path.dirname(env_etc.spotfinder_dist),
  env_etc.boost_adaptbx_include,
  env_etc.boost_include,
  env_etc.annlib_dist,
  env_etc.annlib_include[0],
  env_etc.annlib_include[1],
  env_etc.annlib_adaptbx_include[0],
  env_etc.annlib_adaptbx_include[1],
]

env = env_base.Clone(
  SHLINKFLAGS=env_etc.shlinkflags)
if (libtbx.manual_date_stamp < 20090819):
  # XXX backward compatibility 2009-08-19
  env.Replace(CXXFLAGS=env_etc.cxxflags_base)
  env.Replace(SHCXXFLAGS=env_etc.cxxflags_base)
env_etc.include_registry.append(
  env=env,
  paths=env_etc.spotfinder_common_includes)

envlm = env.Clone(
  LIBS=["ann","omptbx"]+env_etc.libm
)

boost_libs = "#"+os.path.join(os.path.basename(env_etc.boost_dist), "libs")
lib_spotfinder_sources = [
  "core_toolbox/spot.cpp",
  "core_toolbox/libdistl.cpp",
  "core_toolbox/hough.cpp",
  "core_toolbox/distl.cpp",
  "core_toolbox/spotfilter.cpp",
]

if (env_etc.static_libraries): builder = envlm.StaticLibrary
else:                          builder = envlm.SharedLibrary
builder(
    target="#lib/spotfinder",
    source=lib_spotfinder_sources)

if (not env_etc.no_boost_python):
  Import("env_no_includes_boost_python_ext")

  env_spotfinder_boost_python_ext = env_no_includes_boost_python_ext.Clone()
  env_spotfinder_boost_python_ext.Prepend(LIBS=[ "scitbx_boost_python"])
  env_etc.include_registry.append(
    env=env_spotfinder_boost_python_ext,
    paths=env_etc.spotfinder_common_includes + [env_etc.python_include])
  Export("env_spotfinder_boost_python_ext")
  SConscript("core_toolbox/boost_python/SConscript")
  SConscript("array_family/SConscript")

#Note regarding the libtbx_config file:
# rule of thumb for classifying dependencies.  If the package has
# .py files needed at run time, put it in for_use.  If package is
# built entirely at compile time, put it in for_build
