################################################################################
###
### Copyright (C) 2009      University of Toronto
###
################################################################################
###
###  module     : build script
###
###  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 -g'
  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 = ['gsl', 'gslcblas', 'gfortran', 'fftw3'] 
libs_str_user = ['cutil', 'etop', 'rotmat'];

# 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'
elif 'Darwin' == platform.system():
  for i in range(len(libs_str_user)):
    libs_str_user[i] += '_i386'

libs_str += libs_str_user

# include directories (some of them are Linux / Mac only)
inc_dirs = ['./', './inc', './inl',
            '/usr/include/gsl',
            '/usr/local/include/', '/usr/local/include/gsl'];
# library directories (some of them are Linux / Mac only)
lib_dirs = ['./lib', '/usr/local/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/halton.cpp", "src/pinchon.c"]

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


