name = 'R'
version = '3.0.2'

homepage = 'http://www.r-project.org/'
description = """R is a free software environment for statistical local_computing and graphics."""

toolchain = {'name': 'goolf', 'version': '1.4.10'}

sources = [SOURCE_TAR_GZ]
source_urls = ['http://cran.us.r-project.org/src/base/R-%(version_major)s']

preconfigopts = 'BLAS_LIBS="$LIBBLAS" LAPACK_LIBS="$LIBLAPACK"'
configopts = "--with-lapack --with-blas --with-pic --enable-threads --with-x=no --enable-R-shlib"
# some recommended packages may fail in a parallel build (e.g. Matrix),
# and we're installing them anyway below
configopts += " --with-recommended-packages=no"

dependencies = [
    ('libreadline', '6.2'),
    ('ncurses', '5.9'),
    ('libpng', '1.6.6'),  # for plotting in R
    # Java bindings are built if Java is found, might as well provide it
    ('Java', '1.7.0_21', '', True),
]

sanity_check_paths = {
    'files': [
        'bin/%s' %
        x for x in [
            'R',
            'Rscript']] +
    [
        'lib64/R/include/%s' %
        x for x in [
            'Rconfig.h',
            'Rdefines.h',
            'Rembedded.h',
            'R.h',
            'Rinterface.h',
            'Rinternals.h',
            'Rmath.h',
            'Rversion.h',
            'S.h']] +
    [
        'lib64/R/modules/%s' %
        x for x in [
            'internet.%s' %
            SHLIB_EXT,
            'lapack.%s' %
            SHLIB_EXT,
            'vfonts.%s' %
            SHLIB_EXT]] +
    [
        'lib64/R/lib/libR.%s' %
        SHLIB_EXT],
    'dirs': []}

local_name_tmpl = '%(name)s_%(version)s.tar.gz'
local_ext_options = {
    'source_urls': [
        # package archive
        'http://cran.r-project.org/src/contrib/Archive/%(name)s',
        'http://cran.freestatistics.org/src/contrib',  # alternative for packages
    ],
    'source_tmpl': local_name_tmpl,
}
# Bioconductor packages have a different download url
local_bioconductor_options = {
    'source_urls': [
        'http://www.bioconductor.org/packages/release/bioc/src/contrib/',
        'http://www.bioconductor.org/packages/2.13/bioc/src/contrib/',
    ],
    'source_tmpl': local_name_tmpl,
}

# some packages seem to only be in rforge, not in cran
local_rforge_options = {
    'source_urls': ['http://download.r-forge.r-project.org/src/contrib/'],
    'source_tmpl': local_name_tmpl,
}


# !! order of packages is important !!
exts_list = [
    # default libraries, only here to sanity check their presence
    'base',
    'datasets',
    'graphics',
    'grDevices',
    'grid',
    'methods',
    'splines',
    'stats',
    'stats4',
    'tools',
    'utils',
    # non-standard libraries, should be specified with fixed versions!
    ('irace', '1.04', local_ext_options),
    ('rJava', '0.9-4', local_ext_options),
    ('lattice', '0.20-24', local_ext_options),
    ('RColorBrewer', '1.0-5', local_ext_options),
    ('latticeExtra', '0.6-26', local_ext_options),
    ('Matrix', '1.1-0', local_ext_options),
    ('png', '0.1-6', local_ext_options),
    ('Rcpp', '0.10.6', local_ext_options),
    ('quadprog', '1.5-5', local_ext_options),
    ('BB', '2013.4-1', local_ext_options),
    ('rlecuyer', '0.3-3', local_ext_options),
    ('snow', '0.3-13', local_ext_options),
    ('MASS', '7.3-29', local_ext_options),
    ('class', '7.3-9', local_ext_options),
    ('e1071', '1.6-1', local_ext_options),
    ('nnet', '7.3-7', local_ext_options),
    ('car', '2.0-19', local_ext_options),
    ('colorspace', '1.2-4', local_ext_options),
    ('robustbase', '0.9-10', local_ext_options),
    ('sp', '1.0-14', local_ext_options),
    ('vcd', '1.3-1', local_ext_options),
    ('snowfall', '1.84-4', local_ext_options),
    ('rpart', '4.1-3', local_ext_options),
    ('mice', '2.18', local_ext_options),
    ('nlme', '3.1-111', local_ext_options),
    ('mgcv', '1.7-27', local_ext_options),
    ('logistf', '1.21', local_ext_options),
    ('akima', '0.5-11', local_ext_options),
    ('bitops', '1.0-6', local_ext_options),
    ('boot', '1.3-9', local_ext_options),
    ('cluster', '1.14.4', local_ext_options),
    ('coda', '0.16-1', local_ext_options),
    ('codetools', '0.2-8', local_ext_options),
    ('DBI', '0.2-7', local_ext_options),
    ('foreign', '0.8-57', local_ext_options),
    ('survival', '2.37-4', local_ext_options),
    ('gam', '1.09', local_ext_options),
    ('gamlss.data', '4.2-6', local_ext_options),
    ('gamlss.dist', '4.2-0', local_ext_options),
    ('hwriter', '1.3', local_ext_options),
    ('KernSmooth', '2.23-10', local_ext_options),
    ('zoo', '1.7-10', local_ext_options),
    ('lmtest', '0.9-32', local_ext_options),
    ('mnormt', '1.4-5', local_ext_options),
    ('mvtnorm', '0.9-9996', local_ext_options),
    ('numDeriv', '2012.9-1', local_ext_options),
    ('pscl', '1.04.4', local_ext_options),
    ('RSQLite', '0.11.4', local_ext_options),
    ('sandwich', '2.3-0', local_ext_options),
    ('sfsmisc', '1.0-24', local_ext_options),
    ('spatial', '7.3-7', local_ext_options),
    ('VGAM', '0.9-3', local_ext_options),
    ('waveslim', '1.7.1', local_ext_options),
    ('xtable', '1.7-1', local_ext_options),
    ('profileModel', '0.5-9', local_ext_options),
    ('brglm', '0.5-9', local_ext_options),
    ('deSolve', '1.10-8', local_ext_options),
    ('odesolve', '0.9-9', local_ext_options),
    ('tseriesChaos', '0.1-13', local_ext_options),
    ('tseries', '0.10-32', local_ext_options),
    ('neuRosim', '0.2-10', local_ext_options),
    ('fastICA', '1.2-0', local_ext_options),
    ('R.methodsS3', '1.5.2', local_ext_options),
    ('R.oo', '1.15.8', local_ext_options),
    ('R.matlab', '2.0.5', local_ext_options),
    ('Rniftilib', '0.0-32', local_ext_options),
    ('BiocGenerics', '0.8.0', local_bioconductor_options),
    ('Biobase', '2.22.0', local_bioconductor_options),
    ('IRanges', '1.20.5', local_bioconductor_options),
    ('AnnotationDbi', '1.24.0', local_bioconductor_options),
    ('XVector', '0.2.0', local_bioconductor_options),
    ('Biostrings', '2.30.0', local_bioconductor_options),
    ('GenomicRanges', '1.14.3', local_bioconductor_options),
    ('BSgenome', '1.30.0', local_bioconductor_options),
    ('zlibbioc', '1.8.0', local_bioconductor_options),
    ('Rsamtools', '1.14.1', local_bioconductor_options),
    ('ShortRead', '1.20.0', local_bioconductor_options),
    ('graph', '1.40.0', local_bioconductor_options),
    ('igraph0', '0.5.7', local_ext_options),
    ('gbm', '2.1', local_ext_options),
    ('plyr', '1.8', local_ext_options),
    ('dichromat', '2.0-0', local_ext_options),
    ('Formula', '1.1-1', local_ext_options),
    ('Hmisc', '3.13-0', local_ext_options),
    ('stringr', '0.6.2', local_ext_options),
    ('munsell', '0.4.2', local_ext_options),
    ('labeling', '0.2', local_ext_options),
    ('scales', '0.2.3', local_ext_options),
    ('fastcluster', '1.1.11', local_ext_options),
    ('reshape2', '1.2.2', local_ext_options),
    ('digest', '0.6.3', local_ext_options),
    ('gtable', '0.1.2', local_ext_options),
    ('proto', '0.3-10', local_ext_options),
    ('ggplot2', '0.9.3.1', local_ext_options),
    ('leaps', '2.9', local_ext_options),
    ('survival', '2.37-4', local_ext_options),
    ('speff2trial', '1.0.4', local_ext_options),
    ('nleqslv', '2.1', local_ext_options),
    ('glmnet', '1.9-5', local_ext_options),
    ('pim', '1.1.5.4', local_rforge_options),
]

moduleclass = 'lang'
