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

name                libxl
version             3.9.4.3
revision            0
checksums           rmd160  27dbd188602aef4da66e2bb739a68ddfbbe958a3 \
                    sha256  e7e272fd309bfc0209ce6de52b3a4716d21a0fbdac006dd578eb68340e8d3ce3 \
                    size    28462901

categories          textproc
platforms           darwin
maintainers         {ryandesign @ryandesign} openmaintainer
license             LibXL

description         library for reading and writing Microsoft Excel files

long_description    LibXL is a commercial ${description}.

homepage            https://www.libxl.com
master_sites        ${homepage}/download/
dist_subdir         ${name}/${version}
distname            libxl-mac-${version}
use_dmg             yes

worksrcdir          ${distname}/${distname}

use_configure       no

variant universal {}

# The pre-compiled library is built for these architectures.
supported_archs     arm64 x86_64

# The pre-compiled library is linked with libc++.
configure.cxx_stdlib libc++

set libxl           lib/libxl.dylib

build {
    system -W ${worksrcpath} "install_name_tool -id ${prefix}/${libxl} ${libxl}"
    if {![variant_exists universal] || ![variant_isset universal]} {
        system -W ${worksrcpath} "lipo -thin ${configure.build_arch} ${libxl} -output ${libxl}"
    }
}

destroot {
    xinstall -m 0644 ${worksrcpath}/${libxl} ${destroot}${prefix}/lib
    # I don't know where the developers intend these to be installed but they
    # need to be in separate directories because there are files of the same
    # names with different contents. Having them directly in ${prefix}/include
    # also seems inadvisable due to the generically-named enum.h and setup.h.
    # which could conflict with other projects.
    copy ${worksrcpath}/include_c ${destroot}${prefix}/include/libxl-c
    copy ${worksrcpath}/include_cpp ${destroot}${prefix}/include/libxl-cpp

    xinstall -d ${destroot}${prefix}/share/doc
    copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${subport}
    xinstall -m 0644 -W ${worksrcpath} changelog.txt license.txt readme.txt ${destroot}${prefix}/share/doc/${subport}
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/doc/${subport}/
}

livecheck.url       ${homepage}/download.html
livecheck.regex     download/libxl-mac-(\[0-9.\]+)${extract.suffix}

notes "
LibXL is commercial software that requires a license to unlock all features.\
For more information, see:

${homepage}/purchase.html
"
