# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 107013 2013-06-14 12:32:42Z ram@macports.org $

set perl_vendor_lib [ exec sh -c "eval \"\`perl -V:installvendorlib\`\" ; echo \$installvendorlib" ]

if {$build_arch == "x86_64" || $build_arch == "ppc64"} {
    set flavor gcc64pthr
    set enable64 yes
} else {
    set flavor gcc32pthr
    set enable64 no
}

PortSystem              1.0

name                    globus-core
set _name               [ string map {"-" "_"} $name ]
version                 8.9
set globus_version      5.2.4
set globus_branch       [join [lrange [split ${globus_version} .] 0 1] .]
revision                0
platforms               darwin
categories              devel
license                 Apache-2
maintainers             nikhef.nl:dennisvd openmaintainer
homepage                http://www.globus.org/

description             Globus Toolkit - Globus Core
long_description        The Globus Toolkit is an open source software \
                        toolkit used for building Grid systems and \
                        applications. It is being developed by the \
                        Globus Alliance and many others all over the \
                        world. A growing number of projects and \
                        companies are using the Globus Toolkit to \
                        unlock the potential of grids for their \
                        cause. The ${name} package contains: \
                        Globus Core

master_sites            http://www.globus.org/ftppub/gt5/${globus_branch}/${globus_version}/packages/src/

distname                ${_name}-${version}

checksums               sha256 75d58415fdcf344ef3c6a4c1214b29a83035bfc014f43b980607b0929998c9c0 \
                        rmp160 2ca5cdaa7e77c4467409a01cdb0d379bd15a5c7f

patchfiles              patch-globus-core-automake-obsolete-macro.diff

patch.pre_args          -p1

depends_run             port:p5-xml-dom \
                        port:p5-xml-parser

depends_build           port:grid-packaging-tools \
                        port:p5-xml-dom \
                        port:p5-xml-parser \
                        port:libtool \
                        port:autoconf \
                        port:automake

configure.env-append    GPT_LOCATION=${prefix} \
                        GLOBUS_LOCATION=${prefix} \
                        CPPFLAGS="-I${prefix}/include/globus"

configure.post_args     --includedir=${prefix}/include/globus \
                        --libexecdir='\${datadir}/globus' \
                        --with-threads=pthreads \
                        --with-flavor=${flavor} \
                        --enable-64bit=${enable64} \
                        --with-setupdir='\${datadir}/globus/setup' \
                        --with-testdir='\${datadir}/globus/test' \
                        --with-flavorincludedir='\${libdir}/globus/include' \
                        --with-perlmoduledir=${perl_vendor_lib} \
                        --with-doxygendir='\${datadir}/globus/doxygen' \
                        --with-docdir='\${datadir}/doc/${name}'

build.env-append        GPT_LOCATION=${prefix} \
                        GLOBUS_LOCATION=${prefix}

pre-configure {
    file delete -force ${worksrcpath}/autom4te.cache
    reinplace "s/libtoolize/glibtoolize/g" ${worksrcpath}/bootstrap
    system "cd ${worksrcpath} && \
        GLOBUS_LOCATION=${prefix} GPT_LOCATION=${prefix} ./bootstrap"
}

post-destroot {
    # These scripts are intended to be sourced, not executed
    system "chmod 644 ${destroot}${prefix}/share/globus/globus-build-env-*.sh"
}

livecheck.type          regex
livecheck.version       ${globus_version}
livecheck.url           http://www.globus.org/toolkit/downloads/latest-stable/
livecheck.regex         {Globus Toolkit (\d+(?:\.\d+)*) Download}
