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

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

PortSystem              1.0

name                    globus-common
set _name               [ string map {"-" "_"} $name ]
version                 14.9
set setupversion        2.6
revision                1
platforms               darwin
categories              net
license                 Apache-2
maintainers             nikhef.nl:dennisvd fysast.uu.se:mattias.ellert nbi.ku.dk:skou
homepage                http://www.globus.org/

description             Globus Toolkit - Common Library
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: \
                        Common Library and Common Setup

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 6ad0cc8a54ce75b2c31f876538896bca1a6feb140a54274ddb923832f74b6152 \
                            rmp160 b58bfc6957c055a734a20675d396796a59520de0

patchfiles              ${name}-automake-obsolete-macro.patch

patch.pre_args          -p1

depends_run             port:libtool

depends_build           port:grid-packaging-tools \
                        port:globus-core \
                        port:libtool \
                        bin:doxygen:doxygen \
                        bin:dot:graphviz \
                        bin:gs:ghostscript \
                        bin:pdflatex:texlive-latex \
                        port:texlive-latex-recommended \
                        port:texlive-latex-extra \
                        port:texlive-fonts-recommended

worksrcdir              ${_name}-${version}

patch.pre_args          -p1

configure.env-append    GPT_LOCATION=${prefix} \
                        GLOBUS_LOCATION=${prefix} \
                        GLOBUS_VERSION=5.2.2

configure.post_args     --with-flavor=${flavor} --enable-doxygen

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


pre-configure {
    # Remove files that should be replaced during bootstrap
    eval file delete -force \
        [ glob -nocomplain ${worksrcpath}/doxygen/Doxyfile* ] dummy
    file delete -force ${worksrcpath}/doxygen/Makefile.am
    file delete -force ${worksrcpath}/pkgdata/Makefile.am
    eval file delete -force \
        [ glob -nocomplain ${worksrcpath}/globus_automake* ] dummy
    file delete -force ${worksrcpath}/autom4te.cache

    system "cd $worksrcpath && \
        GPT_LOCATION=${prefix} GLOBUS_LOCATION=${prefix} \
        ${prefix}/share/globus/globus-bootstrap.sh"

}


post-destroot {
    # These scripts are intended to be sourced, not executed
    system "chmod 644 ${destroot}${prefix}/share/globus/globus-args-parser-header"
    system "chmod 644 ${destroot}${prefix}/share/globus/globus-script-initializer"
    system "chmod 644 ${destroot}${prefix}/share/globus/globus-sh-tools.sh"

    # Remove libtool archives (.la files)
    foreach file [ exec find ${destroot}/${prefix}/lib -name "lib*.la" ] {
        delete $file
    }

    # Remove static libraries (.a files)
    foreach file [ exec find ${destroot}/${prefix}/lib -name "lib*.a" ] {
        delete $file
    }

    # Move documentation to default macports location
    move ${destroot}${prefix}/share/doc/${_name} \
        ${destroot}${prefix}/share/doc/${name}-${version}

    # Remove deprecated.3 man page (too common name)
    delete ${destroot}${prefix}/share/man/man3/deprecated.3
    reinplace "/deprecated\\.3/d" \
        ${destroot}${prefix}/share/globus/packages/${_name}/noflavor_doc.filelist

}
