easyblock = 'EB_GCC'

name = 'GCCcore'
version = '6.2.0'

homepage = 'http://gcc.gnu.org/'
description = """The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Java, and Ada,
 as well as libraries for these languages (libstdc++, libgcj,...)."""

toolchain = {'name': 'system', 'version': ''}

mpfr_version = '3.1.4'

source_urls = [
    # GCC auto-resolving HTTP mirror
    'http://ftpmirror.gnu.org/gcc/gcc-%(version)s',
    'http://ftpmirror.gnu.org/gmp',  # idem for GMP
    'http://ftpmirror.gnu.org/mpfr',  # idem for MPFR
    'http://www.multiprecision.org/mpc/download',  # MPC official
    'ftp://gcc.gnu.org/pub/gcc/infrastructure/',  # GCC dependencies
    'http://gcc.cybermirror.org/infrastructure/',  # HTTP mirror for GCC dependencies
    'http://isl.gforge.inria.fr/',  # original HTTP source for ISL
]

sources = [
    'gcc-%(version)s.tar.bz2',
    'gmp-6.1.1.tar.bz2',
    'mpfr-%s.tar.bz2' % mpfr_version,
    'mpc-1.0.3.tar.gz',
    'isl-0.16.1.tar.bz2',
]

builddependencies = [
    ('M4', '1.4.17'),
    ('binutils', '2.27'),
]

patches = [
    ('mpfr-%s-allpatches-20160804.patch' %
     mpfr_version,
     '../mpfr-%s' %
     mpfr_version),
    '%(name)s-%(version)s-fix-find-isl.patch',
]

checksums = [
    '9768625159663b300ae4de2f4745fcc4',     # gcc-6.2.0.tar.bz2
    '4c175f86e11eb32d8bf9872ca3a8e11d',     # gmp-6.1.1.tar.bz2
    'b8a2f6b0e68bef46e53da2ac439e1cf4',     # mpfr-3.1.4.tar.gz
    'd6a1d5f8ddea3abd2cc3e98f58352d26',     # mpc-1.0.3.tar.gz
    'ac1f25a0677912952718a51f5bc20f32',     # isl-0.16.1.tar.bz2
]

languages = ['c', 'c++', 'fortran']

withisl = True

moduleclass = 'compiler'

# Salomon specific optimalization
modextravars = {
    'CC': '%(installdir)s/bin/gcc',
    'CXX': '%(installdir)s/bin/g++',
    'F90': '%(installdir)s/bin/gfortran',
    'F77': '%(installdir)s/bin/gfortran',
    'FC': '%(installdir)s/bin/gfortran',
    'F9X': '%(installdir)s/bin/gfortran',
    'OPTFLAGS': '-O3 -march=native',
    'DEBUGFLAGS': '-O0 -g'
}
