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

PortSystem          1.0

name                stm32flash
version             0.4
categories          devel
maintainers         openmaintainer gmail.com:ranauei
platforms           darwin
license             GPL-2
description         Flash program for the STM32 bootloader
long_description    Open source flash program for the STM32 ARM processors \
                    using the ST serial bootloader over UART or I2C
homepage            http://sourceforge.net/p/stm32flash/wiki/Home/
master_sites        sourceforge

checksums           rmd160  f40648bd6baf5943c781c955ab260851c9cee744 \
                    sha256  023f28b01f644edc235c8815a4352e359d3ebdbe6368aaf6bbc28bab3e6ffa5b

worksrcdir          ${name}

use_configure       no

variant universal {}

patchfiles          patch-stm32.c.diff

post-patch {
     reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/Makefile
     reinplace "s|\$\(AR\) rc|\$\(AR\) rcs|g" ${worksrcpath}/parsers/Makefile
}

build.env-append    CFLAGS="${configure.cflags} [get_canonical_archflags cc]" \
                    LDFLAGS="${configure.ldflags} [get_canonical_archflags ld]"

build.args-append   CC=${configure.cc}
build.env-append    MAKE=${build.cmd} \
                    INSTALL=${configure.install}