# -*- 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                libftd2xx
version             1.2.2
categories          devel
maintainers         nomaintainer
description         FTDI D2XX Driver
long_description    D2XX Driver: allow direct access to the USB device through \
                    a DLL. Devices supported: FT2232H, FT4232H, FT232R, \
                    FT245R, FT2232, FT232B, FT245B, FT8U232AM, FT8U245AM
                  
homepage            http://www.ftdichip.com/Drivers/D2XX.htm
platforms           macosx
distname            D2XX${version}
master_sites        http://www.ftdichip.com/Drivers/D2XX/MacOSX/

checksums           rmd160  d9fb6ceba3de5aaa87978e04bd6eb3b27ce8c2ef \
                    sha256  7d6f39b4d092be2687321729e70ff8d08c20e288f7f036e1fdc19116c20a3250

use_dmg             yes
use_configure       no

variant universal {}

if { ${os.major}=="8" } {
    set os_dir 10.4
    set static_dir static32
    supported_archs     i386 ppc
    configure.universal_archs i386 ppc
} elseif { ${os.major}>=9 } {
    set os_dir 10.5-10.7
    set static_dir static64
    supported_archs     i386 ppc x86_64
    configure.universal_archs i386 ppc x86_64
}

build {
    if {![variant_isset universal]} {
        system "cd '${worksrcpath}/D2XX/bin/${os_dir}' && lipo -extract ${configure.build_arch} ${name}.${version}.dylib -output ${name}.${version}.dylib"
    }
}

destroot {
   xinstall ${worksrcpath}/D2XX/bin/${os_dir}/${name}.${version}.dylib ${destroot}${prefix}/lib
   xinstall ${worksrcpath}/D2XX/bin/${static_dir}/${name}.a ${destroot}${prefix}/lib
   xinstall -m 644 ${worksrcpath}/D2XX/bin/ftd2xx.cfg ${destroot}${prefix}/lib
   xinstall -m 644 -W ${worksrcpath}/D2XX/bin ftd2xx.h WinTypes.h ${destroot}${prefix}/include
   ln -s ${name}.${version}.dylib ${destroot}${prefix}/lib/${name}.dylib
   system "install_name_tool -id ${prefix}/lib/${name}.${version}.dylib ${destroot}${prefix}/lib/${name}.${version}.dylib"
}

livecheck.type      regex
livecheck.regex     D2XX(\[0-9.\]+)${extract.suffix}
