################################################################################
###
### Copyright (C) 2009      University of Toronto
###
################################################################################
###
###  module     : condition number optimization
###
###  author     : lessig@dgp.toronto.edu
###
###  project    : Spherical Harmonics rotation
###
###  description: Scons build script
###
###  license    : See README for details.
###
################################################################################

# imports, scons
import platform

# Distinguish between debug (default) and release builds (specify 'release=1'
# on the command line
if ARGUMENTS.get( 'release', 0):
  cc_flags = '-O2'
  executable = 'bin/release/main'
else:
  cc_flags = '-g -DDEBUG'
  executable = 'bin/debug/main'

# add command command line flags for the compiler
cc_flags = cc_flags + ' -W -Wall'

# libraries 
libs_str = ['gfortran', 'f2c', 'lapack', 'blas'] 
libs_str_user = ['routines']

# append OS specific post fix if necessary
if 'x86_64' == platform.machine():
  for i in range(len(libs_str_user)):
    libs_str_user[i] += '_x86_64'

libs_str += libs_str_user

# include directories (some of them are Linux / Mac only)
inc_dirs = ['./', './inc', './inl', '../inc', '../inl']
# library directories (some of them are Linux / Mac only)
lib_dirs = ['./lib', 
            '/opt/local/lib', 
            '/usr/local/gfortran/lib/x86_64/', 
            '../lib'];

# Set up build environment
env = Environment( CCFLAGS = cc_flags, CFLAGS = cc_flags,
                   CPPPATH = inc_dirs,
                   LIBS  = libs_str,
                   LIBPATH = lib_dirs )

sources = [ 'src/main.cpp', 
            'src/BFGSwrap.cpp', 
            'src/energy.cpp', 
            'src/file_io.cpp',
            'src/optimizer.cpp']

# Build
env.Program( target = executable, source = sources)


