# -*- 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                openocd
version             0.12.0
revision            0
categories          cross devel
license             GPL
maintainers         {snc @nerdling} openmaintainer
description         Open On-Chip Debugger
long_description    The Open On-Chip Debugger (OpenOCD) aims to provide \
                    debugging, in-system programming and boundary-scan \
                    testing for embedded target devices. Built with support \
                    for FT2232-based programmers by default. See variants for \
                    programmer options.
homepage            http://openocd.sourceforge.net/
platforms           darwin

master_sites        sourceforge:project/openocd/openocd/${version}

use_bzip2           yes
checksums           sha1    a5ab82ba1d4b13634fbb4556699714d5996e37bb \
                    rmd160  00176d45a251ac40c507941e291ef0111f0bf471 \
                    sha256  af254788be98861f2bd9103fe6e60a774ec96a8c374744eef9197f6043075afa \
                    size    6790673

configure.args-append  --disable-werror --enable-maintainer-mode --disable-silent-rules

depends_build-append	port:pkgconfig

if {![variant_isset ft2232_ftd2xx]} {
    default_variants +ftdi
}

variant dummy description {Enable building the dummy port driver} {
    configure.args-append --enable-dummy
}

variant parport description {Enable building the pc parallel port driver. WARNING: not supported on OS X.} {
    configure.args-append --enable-parport
}

variant ftdi conflicts ft2232_ftd2xx description {Enable building OpenOCD's built-in FTDI driver.} {
    configure.args-append --enable-ftdi
	depends_lib-append path:lib/pkgconfig/libusb-1.0.pc:libusb
}

# The ft2232 variant is deprecated, the ftdi variant is its replacement
variant ft2232 conflicts ft2232_ftd2xx  description {Enable building support for FT2232 based devices using the libftdi driver, opensource alternate of FTD2XX} {
    configure.args-append --enable-legacy-ft2232_libftdi
	depends_lib-append port:libftdi1
}

# The ft2232_ftd2xx variant is deprecated, the ftdi variant is its replacement
variant ft2232_ftd2xx conflicts ft2232  description {Enable building support for FT2232 based devices using the FTD2XX driver from ftdichip.com} {
    patchfiles-append patch-ftd2xx-path.diff
    use_autoreconf      yes
    configure.args-append --enable-legacy-ft2232_ftd2xx
	depends_lib-append port:libftd2xx
}

variant usb_blaster conflicts usb_blaster_ftd2xx description {Enable building support for the Altera USB-Blaster using the libftdi driver, opensource alternate of FTD2XX} {
    configure.args-append --enable-usb_blaster_libftdi
	depends_lib-append port:libftdi1
}

variant usb_blaster_ftd2xx conflicts usb_blaster description {Enable building support for the Altera USB-Blaster using the FTD2XX driver from ftdichip.com} {
    patchfiles-append patch-ftd2xx-path.diff
    use_autoreconf      yes
    configure.args-append --enable-usb_blaster_ftd2xx
	depends_lib-append port:libftd2xx
}

variant amtjtagaccel description {Enable building the Amontec JTAG-Accelerator driver} {
    configure.args-append --enable-amtjtagaccel
}

variant ecosboard description {Enable building support for eCos based JTAG debugger} {
    configure.args-append --enable-ecosboard
}

variant zy1000_master requires zy1000 description {Use ZY1000 JTAG master registers} {
    configure.args-append --enable-zy1000-master
}

variant zy1000 conflicts minidriver_dummy description {Enable ZY1000 interface. WARNING: Using the minidriver disables all other drivers.} {
    configure.args-append --enable-zy1000
}

variant ioutil description {Enable ioutil functions - useful for standalone OpenOCD implementations} {
    configure.args-append --enable-ioutil
}

variant ep93xx description {Enable building support for EP93xx based SBCs} {
    configure.args-append --enable-ep93xx
}

variant at91rm9200 description {Enable building support for AT91RM9200 based SBCs} {
    configure.args-append --enable-at91rm9200
}

variant gw16012 description {Enable building support for the Gateworks GW16012 JTAG Programmer} {
    configure.args-append --enable-gw16012
}

variant presto conflicts presto_ftd2xx description {Enable building support for ASIX Presto Programmer using the libftdi driver} {
    configure.args-append --enable-presto_libftdi
	depends_lib-append port:libftdi1
}

variant presto_ftd2xx conflicts presto description {Enable building support for ASIX Presto Programmer using the FTD2XX driver} {
    configure.args-append --enable-presto_ftd2xx
	depends_lib-append port:libftd2xx
}

variant usbprog description {Enable building support for the usbprog JTAG Programmer} {
    configure.args-append --enable-usbprog
}

variant oocd_trace description {Enable building support for some prototype OpenOCD+trace ETM capture hardware} {
    configure.args-append --enable-oocd_trace
}

variant jlink description {Enable building support for the Segger J-Link JTAG Programmer} {
    configure.args-append --enable-jlink
}

variant vsllink description {Enable building support for the Versaloon-Link JTAG Programmer} {
    configure.args-append --enable-vsllink
}

variant rlink description {Enable building support for the Raisonance RLink JTAG Programmer} {
    configure.args-append --enable-rlink
}

variant ulink description {Enable building support for the Keil ULINK JTAG Programmer} {
    configure.args-append --enable-ulink
}

variant arm_jtag_ew description {Enable building support for the Olimex ARM-JTAG-EW Programmer} {
    configure.args-append --enable-arm-jtag-ew
}

variant buspirate description {Enable building support for the Buspirate} {
    configure.args-append --enable-buspirate
}

variant minidriver_dummy conflicts zy1000 description {Enable the dummy minidriver} {
    configure.args-append --enable-minidriver-dummy
}

variant stlink description {Enable building support for the STM ST-link} {
    configure.args-append --enable-stlink
    depends_lib-append  path:lib/pkgconfig/libusb-1.0.pc:libusb
}

variant ti description {TI-ICDI interface on Stellaris Launchpad} {
    configure.args-append --enable-ti-icdi
    depends_lib-append  path:lib/pkgconfig/libusb-1.0.pc:libusb
}

variant cmsis description {Enable building support for the cmsis-dap} {
    configure.args-append --enable-cmsis-dap
    depends_lib-append  port:hidapi
}

variant remote_bitbang description {Enable building support for the Remote Bitbang jtag driver} {
    configure.args-append --enable-remote-bitbang
}

test.run            yes
test.target         check

livecheck.regex     "/${name}-(\\d+(\\.\\d+)+)\\.tar"
