# -*- 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 105620 2013-04-28 01:23:09Z aronnax@macports.org $

PortSystem          1.0

name                healpix
set base_version    3.11
version             ${base_version}_2013Apr24
categories          science
license             GPL-2
maintainers         aronnax
description         Hierarchical Equal Area isoLatitude Pixelization of a sphere
long_description    Software for pixelization, hierarchical indexation, synthesis, \
                    analysis, and visualization of data on the sphere.
homepage            http://healpix.jpl.nasa.gov/
platforms           darwin
master_sites        sourceforge:project/${name}/Healpix_${base_version}/
distname            Healpix_${version}
worksrcdir          Healpix_${base_version}

checksums           md5     6ddfb66dbc2f57478cb328ec76c510d9 \
                    sha1    f7d6a18ca6aad9fe85a66eca36d7a1f0ef783e95 \
                    rmd160  615d52e1bd99f81c96f4e0dc131cc3bc865f85d0

if {${name} == ${subport}} {
    supported_archs noarch

    depends_run     port:${name}-c \
                    port:${name}-cxx \
                    port:${name}-java

    distfiles

    use_configure   no

    build {}

    destroot {
        xinstall -d ${destroot}${prefix}/share/doc/${subport}
        system "echo ${subport} is a stub port > ${destroot}${prefix}/share/doc/${subport}/README.txt"
    }

    livecheck.regex {healpix/files/Healpix_([0-9]+\.[0-9]+[a-z]?)}
} else {

    pre-activate {
        if {[file exists ${prefix}/lib/libchealpix.a]
            && ![catch {set vers [lindex [registry_active healpix] 0]}]
            && [vercmp [lindex $vers 1] 3.00] < 0} {
            registry_deactivate_composite healpix "" [list ports_nodepcheck 1]
        }
    }

    livecheck.type  none
}

subport ${name}-c {
    description         C language implementation of HEALPix
    long_description    ${long_description} This is the ${description}.

    worksrcdir          Healpix_${base_version}/src/C/autotools

    depends_build       port:pkgconfig
    depends_lib         port:cfitsio

    use_autoreconf      yes
}

subport ${name}-cxx {
    description         C++ language implementation of HEALPix
    long_description    ${long_description} This is the ${description}.

    worksrcdir          Healpix_${base_version}/src/cxx/autotools

    depends_build       port:pkgconfig
    depends_lib         port:cfitsio

    use_autoreconf      yes

    default_variants    +openmp

    variant openmp description "enable OpenMP parallel acceleration" {
        compiler.blacklist clang
    }
}

subport ${name}-java {
    description         Java language implementation of HEALPix
    long_description    ${long_description} This is the ${description}.

    supported_archs noarch

    patchfiles      patch-build.xml.diff

    depends_build   bin:javac:jikes bin:jar:jikes
    depends_lib     bin:java:kaffe

    use_configure   no

    worksrcdir      Healpix_${base_version}/src/java
    build.cmd       ant
    build.target    dist

    destroot {
        xinstall -d ${destroot}${prefix}/share/java
        eval xinstall [glob ${worksrcpath}/dist/*.jar] ${destroot}${prefix}/share/java
    }
}
