# $Id: Portfile,v 1.16 2006/06/29 20:46:52 gwright Exp $

PortSystem 1.0
name             R
version          2.3.1
categories       math science
maintainers      konis@stats.ox.ac.uk
platforms        darwin
description      R is GNU S - an interpreted language for statistical computing
long_description \
    R is a language and environment for statistical computing and graphics. \
    R provides a wide variety of statistical (linear and nonlinear modelling, \
    classical statistical tests, time-series analysis, classification, \
    clustering, ...) and graphical techniques, and is highly extensible.

homepage         http://www.r-project.org/
master_sites     http://cran.r-project.org/src/base/R-2/ \
                 http://cran.us.r-project.org/src/base/R-2/ \
                 http://cran.au.r-project.org/src/base/R-2/ \
                 http://cran.at.r-project.org/src/base/R-2/ \
                 http://cran.hu.r-project.org/src/base/R-2/

checksums        md5 a1d6d8081af4c71006a6e5a3ed54e4da \
                 sha1 62cf87f4a273f17d5a55a5ffaf0bfcdfdae3c03d \
                 rmd160 061a77f25d3b1144aecdce479aa707e7bea21a82

depends_build    port:gcc40 \
                 port:teTeX

depends_lib      port:readline \
                 port:gettext \
                 lib:libjpeg:jpeg \
                 lib:libpng:libpng

configure.env    CPPFLAGS="-I${prefix}/include" \
                 LDFLAGS="-L${prefix}/lib" \
                 CC=${prefix}/bin/gcc-dp-4.0 \
                 CXX=${prefix}/bin/g++-dp-4.0 \
                 F77=${prefix}/bin/gfortran-dp-4.0

configure.args   --mandir=\\\${prefix}/share/man \
                 --enable-R-shlib \
                 --disable-R-framework \
                 --without-aqua

test.run         yes
test.target      check
destroot.destdir prefix=${destroot}${prefix}

platform darwin 6 {
    depends_lib-append lib:libdl:dlcompat
}

platform darwin 7 {
    depends_lib-append port:tcl \
                       port:tk
    configure.args-append --with-tcl-config=${prefix}/lib/tclConfig.sh \
                          --with-tk-config=${prefix}/lib/tkConfig.sh
}

post-destroot {
    reinplace "s|R_HOME_DIR=${destroot}|R_HOME_DIR=|" \
        "${destroot}${prefix}/bin/R"
    reinplace "s|R_HOME_DIR=${destroot}|R_HOME_DIR=|" \
        "${destroot}${prefix}/lib/R/bin/R"
    reinplace "s|R_SHARE_DIR=${destroot}|R_SHARE_DIR=|" \
        "${destroot}${prefix}/bin/R"
    reinplace "s|R_SHARE_DIR=${destroot}|R_SHARE_DIR=|" \
        "${destroot}${prefix}/lib/R/bin/R"
    reinplace "s|R_INCLUDE_DIR=${destroot}|R_INCLUDE_DIR=|" \
        "${destroot}${prefix}/bin/R"
    reinplace "s|R_INCLUDE_DIR=${destroot}|R_INCLUDE_DIR=|" \
        "${destroot}${prefix}/lib/R/bin/R"
    reinplace "s|R_DOC_DIR=${destroot}|R_DOC_DIR=|" \
        "${destroot}${prefix}/bin/R"
    reinplace "s|R_DOC_DIR=${destroot}|R_DOC_DIR=|" \
        "${destroot}${prefix}/lib/R/bin/R"
}

