easyblock = 'EB_GCC'

name = 'GCCcore'
version = '6.4.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,...).  [NOTE: This module does not include Objective-C, Java or Ada]
"""

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

mpfr_version = '3.1.5'

source_urls = [
    # GCC auto-resolving HTTP mirror
    'http://ftpmirror.gnu.org/gnu/gcc/gcc-%(version)s',
    'http://ftpmirror.gnu.org/gnu/gmp',  # idem for GMP
    'http://ftpmirror.gnu.org/gnu/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.gz',
    'gmp-6.1.2.tar.bz2',
    'mpfr-%s.tar.bz2' % mpfr_version,
    'mpc-1.0.3.tar.gz',
    'isl-0.16.1.tar.bz2',
]

builddependencies = [
    ('M4', '1.4.18'),
    ('binutils', '2.28'),
]

patches = [
    ('mpfr-%s-allpatches-20170606.patch' %
     mpfr_version,
     '../mpfr-%s' %
     mpfr_version),
    'GCCcore-6.2.0-fix-find-isl.patch',
]

checksums = [
    '4715f02413f8a91d02d967521c084990c99ce1a671b8a450a80fbd4245f4b728',  # gcc-6.4.0.tar.gz
    '5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2',  # gmp-6.1.2.tar.bz2
    'ca498c1c7a74dd37a576f353312d1e68d490978de4395fa28f1cbd46a364e658',  # mpfr-3.1.5.tar.gz
    '617decc6ea09889fb08ede330917a00b16809b8db88c29c31bfbb49cbf88ecc3',  # mpc-1.0.3.tar.gz
    '412538bb65c799ac98e17e8cfcdacbb257a57362acfaaff254b0fcae970126d2',  # isl-0.16.1.tar.bz2
    '137108952139486755e8c1bee30314ffa9233cc05cddfd848aa85503a6fea9d7',
    # mpfr-3.1.5-allpatches-20170606.patch
    '5ad909606d17d851c6ad629b4fddb6c1621844218b8d139fed18c502a7696c68',
    # GCCcore-6.2.0-fix-find-isl.patch
]

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

withisl = True

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'
}

moduleclass = 'compiler'
