# -*- 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 115936 2014-01-14 21:06:56Z ryandesign@macports.org $

PortSystem          1.0

name                libxl
version             3.5.4.1
set branch          [join [lrange [split ${version} .] 0 2] .]
categories          textproc
platforms           darwin
maintainers         ryandesign openmaintainer
license             LibXL

description         library for reading and writing Microsoft Excel files

long_description    LibXL is a commercial ${description}.

homepage            http://www.libxl.com/
master_sites        ftp://xlware.com/
dist_subdir         ${name}/${version}
distfiles           libxl-mac-${branch}${extract.suffix}

checksums           rmd160  c93ac35863809c8fd80453aec511b45155b50d37 \
                    sha256  0dcb19ce028022b7fedeaa7650414b49bc0be28243742d25a92377e323dc72c9

use_configure       no

variant universal {}

supported_archs     i386 x86_64
configure.universal_archs i386 x86_64

# The pre-compiled library is linked with libstdc++.
if {[info exists configure.cxx_stdlib]} {
    configure.cxx_stdlib libstdc++
}

set libxl           lib/libxl.dylib

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

destroot {
    xinstall -m 644 ${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 ${destroot}${prefix}/share/examples
    copy ${worksrcpath}/doc ${destroot}${prefix}/share/doc/${subport}
    xinstall -W 644 -W ${worksrcpath} changelog.txt license.txt readme.txt ${destroot}${prefix}/share/doc/${subport}
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/examples/${subport}
}

livecheck.version   ${branch}
livecheck.url       ${homepage}download.html
livecheck.regex     {LibXL for Mac ([0-9.]+)}

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

${homepage}purchase.html
"
