name = "GCC"
version = '5.1.0'

local_local_binutilsver = '2.25'
versionsuffix = '-local_binutils-%s' % local_local_binutilsver

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.2'

source_urls = [
    # GCC auto-resolving HTTP mirror
    'http://ftpmirror.gnu.org/%(namelower)s/%(namelower)s-%(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
]

sources = [
    SOURCELOWER_TAR_BZ2,
    'gmp-6.0.0a.tar.bz2',
    'mpfr-%s.tar.gz' % local_mpfr_version,
    'mpc-1.0.3.tar.gz',
    'isl-0.14.tar.bz2',
]

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

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

checksums = [
    'd5525b1127d07d215960e6051c5da35e',     # gcc-5.1.0.tar.bz2
    'b7ff2d88cae7f8085bd5006096eed470',     # gmp-6.0.0a.tar.bz2
    '181aa7bb0e452c409f2788a4a7f38476',     # mpfr-3.1.2.tar.gz
    'd6a1d5f8ddea3abd2cc3e98f58352d26',     # mpc-1.0.3.tar.gz
    'acd347243fca5609e3df37dba47fd0bb',     # isl-0.14.tar.bz2
    '58aec98d15982f9744a043d2f1c5af82',     # mpfr-3.1.2-allpatches-20141204.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'
}
