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

PortSystem          1.0
PortGroup           compilers 1.0

name                wcslib
version             8.2.2
revision            0
checksums           rmd160  25a64f7c448c83ebea221d437e02543fc8a812f9 \
                    sha256  6298220ae817f4e5522643ac4c3da2623be70a3484b1a4f37060bee3e4bd7833 \
                    size    3187577

categories          science
license             LGPL-3+
maintainers         nomaintainer
description         Library for handling World Coordinate System in FITS files
long_description    A C library, with a set of Fortran wrappers, that \
                    implements the World Coordinate System (WCS) standard \
                    in FITS (Flexible Image Transport System). \
                    Select a Fortran compiler variant to enable the Fortran wrappers.
homepage            http://www.atnf.csiro.au/people/mcalabre/WCS/index.html
master_sites        ftp://ftp.atnf.csiro.au/pub/software/wcslib/ \
                    ftp://ftp.eso.org/pub/dfs/pipelines/libraries/wcslib/
use_bzip2           yes

depends_lib         port:cfitsio

universal_variant   no
use_parallel_build  no

patchfiles          install_name.patch \
                    no-strange-places.patch

configure.args      --disable-fortran \
                    --with-cfitsio \
                    --with-cfitsioinc=${prefix}/include \
                    --with-cfitsiolib=${prefix}/lib \
                    --without-pgplot

# https://trac.macports.org/ticket/66253
if {${build_arch} in [list i386 ppc]} {
    configure.ldflags-append -read_only_relocs suppress
}

# The -I flag from CPPFLAGS ends up in the wrong place on the build line
# (before the -I flags for source directories). The build system will add
# its own -I and -L flags from the --with-cfitsioinc and --with-cfitsiolib
# configure args.
configure.cppflags-delete \
                    -I${prefix}/include
configure.ldflags-delete \
                    -L${prefix}/lib

livecheck.type      regex
livecheck.url       http://www.atnf.csiro.au/people/mcalabre/WCS/CHANGES
livecheck.regex     "WCSLIB version (\\d+\\.\\d+\(\\.\\d+\)?)"

compilers.choose    fc f77 f90
compilers.setup

if {[fortran_variant_isset]} {
    depends_lib-append      port:pgplot

    configure.args-replace  --disable-fortran   --enable-fortran
    configure.args-replace  --without-pgplot    --with-pgplot
    configure.args-append   --with-pgplotinc=${prefix}/include \
                            --with-pgplotlib=${prefix}/lib
}
