'''This is the configuration file for the BigDFT installer
for use on the K computer when cross compiling.
'''

conditions.add("testing")

# List the module the this rcfile will build
modules = ['spred', ]


def env_configuration():
    '''
    Species the configure line for various packages.
    '''
    from os import getcwd, path
    env = {}
    env["FC"] = "mpifrt"
    env["F77"] = "frt"
    env["CC"] = "fcc"
    env["CXX"] = "FCC"
    env["FCFLAGS"] = "-SSL2BLAMP -Kfast,openmp,noautoobjstack"
    env["FFLAGS"] = "-Kfast"
    env["CFLAGS"] = "-g -std=gnu99 -O3 -I" + path.join(getcwd(), "install", "include")
    env["--with-ext-linalg"] = "-fjlapackex"
    env["LIBS"] = "-SSL2BLAMP -Kfast,openmp -Nlibomp"
    env["--build"] = "x86_64-redhat-linux"
    env["--host"] = "sparc-fujitsu-linux"

    return " ".join(['"' + x + '=' + y + '"' for x, y in env.items()])

def python_configuration():
    '''
    Specifies the configure line for python packages.
    '''
    return ""

def ntpoly_configuration():
    ''' 
    For NTPoly we need to specify the cmake options.
    ''' 
    from os import getcwd, path

    cmake_flags = {}
    cmake_flags["CMAKE_Fortran_FLAGS_RELEASE"] = "-SSL2BLAMP -Kfast,openmp"
    cmake_flags["FORTRAN_ONLY"] = "YES"
    cmake_flags["CMAKE_Fortran_COMPILER"] = "mpifrt"
    cmake_flags["CMAKE_C_COMPILER"] = "mpifcc"
    cmake_flags["CMAKE_CXX_COMPILER"] = "mpiFCC"
    cmake_flags["CMAKE_PREFIX_PATH"] = path.join(getcwd(), "install")
    cmake_flags["CMAKE_Fortran_MODDIR_FLAG"] = "-M"

    return " ".join(['-D' + x + '="' + y + '"' for x, y in cmake_flags.items()])

module_cmakeargs.update({
    'ntpoly': ntpoly_configuration()
})

autogenargs = env_configuration()

module_autogenargs.update({
   'biopython': python_configuration()
})

