# -*- 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           perl5 1.0
PortGroup           compilers 1.0

perl5.branches      5.28 5.30 5.32 5.34
perl5.setup         Ifeffit 2
epoch               1
version             1.2.13
revision            2

license             Permissive
maintainers         nomaintainer

description         Perl interface to ifeffit

long_description    ${description}

homepage            http://cars9.uchicago.edu/ifeffit/
master_sites        https://github.com/newville/ifeffit/archive/

checksums           rmd160  dedd8b9f6be0d0b0bce67e5f53c18faddf7b0912 \
                    sha256  72a7f5bd6e6e1ff2b41761cfe726f79f2da8e71606399d3c3307451496a1c0ef

dist_subdir         ifeffit
distname            1.2.final
worksrcdir          ifeffit-${distname}/wrappers/perl

# IMPORTANT BUILD NOTES
#
# p5-ifeffit is configured using a Makefile.PL that is generated when ifeffit is built.
# since the paths to the compiler libraries contain compiler version information,
# if the compiler version changes then both ifeffit and p5-ifeffit need to be rebuilt
# so that the Makefile.PL in use contains the correct paths.
#
# if in doubt rebuild everything

if {${perl5.major} != ""} {
    depends_lib-append \
                    port:ifeffit

    compilers.choose    f77
    compilers.setup     require_fortran
    # Undefined symbols: "restGPRx", "__gfortran_transfer_real_write", "__gfortran_transfer_integer_write"
    compiler.blacklist-append \
                        *gcc-4.0 *gcc-4.2

    compilers.enforce_fortran  ifeffit
    # this shows up in the contents of Makefile.PL, as the gcc/gfortran library
    
    pre-configure {
        # copy the preconfigured Makefile.PL generated during the build of ifeffit
        # this must be done in pre-configure to ensure that ifeffit is installed and active
        # before the copy is attempted
        
        copy -force ${prefix}/share/ifeffit/config/Makefile.PL ${worksrcpath}/Makefile.PL
    }
    
    post-configure {
        # Need to patch the generated Makefile due to strange bug
        reinplace "s|^PERL_ARCHIVE *= *$|PERL_ARCHIVE = \$(PERL_INC)/libperl.dylib|" ${worksrcpath}/Makefile
    }
}

# this is the final release of ifeffit
livecheck.type      none
