# -*- 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$

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
revision                2
platforms               darwin
categories              devel
license                 Apache-2
maintainers             nikhef.nl:dennisvd fysast.uu.se:mattias.ellert nbi.ku.dk:skou
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/5.2/5.2.4/packages/src/

distfiles               ${_name}-${version}.tar.gz

checksums               ${_name}-${version}.tar.gz \
                            sha256 75d58415fdcf344ef3c6a4c1214b29a83035bfc014f43b980607b0929998c9c0 \
                            rmp160 2ca5cdaa7e77c4467409a01cdb0d379bd15a5c7f

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

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

worksrcdir              ${_name}-${version}

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}-${version}'

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