easyblock = 'EB_GCC'

name = 'GCCcore'
version = '5.3.1'
local_snapshot = '20160419'
versionsuffix = '-local_snapshot-%s' % local_snapshot

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 = SYSTEM

local_mpfr_version = '3.1.3'
local_gcc_name = 'GCC'

source_urls = [
    'http://gcc.parentingamerica.com/snapshots/LATEST-5/',
    # GCC auto-resolving HTTP mirror
    'http://ftpmirror.gnu.org/gmp',  # idem for GMP
    'http://ftpmirror.gnu.org/mpfr',  # idem for MPFR
    'http://www.multiprecision.org/mpc/download',  # MPC official
]
sources = [
    'gcc-5-%s.tar.bz2' % local_snapshot,
    'gmp-6.1.0.tar.bz2',
    'mpfr-%s.tar.gz' % local_mpfr_version,
    'mpc-1.0.3.tar.gz',
    'isl-0.15.tar.bz2',
]

builddependencies = [('binutils', '2.25')]

patches = [
    ('mpfr-%s-allpatches-20151029.patch' %
     local_mpfr_version,
     '../mpfr-%s' %
     local_mpfr_version)]

checksums = [
    'bf701ac49b63272cf77ba0f272214a38',     # gcc-5-20160419.tar.bz2
    '86ee6e54ebfc4a90b643a65e402c4048',     # gmp-6.1.0.tar.bz2
    '7b650781f0a7c4a62e9bc8bdaaa0018b',     # mpfr-3.1.3.tar.gz
    'd6a1d5f8ddea3abd2cc3e98f58352d26',     # mpc-1.0.3.tar.gz
    '8428efbbc6f6e2810ce5c1ba73ecf98c',     # isl-0.15.tar.bz2
    '6476b450c3db177b2250f3549362380e',     # mpfr-3.1.3-allpatches-20151029.patch
]

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

withisl = True

# building GCC sometimes fails if make parallelism is too high, so let's
# limit it
maxparallel = 4

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