# -*- 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                flashrom
version             1.3.0
categories          sysutils
license             GPL-2
maintainers         {ra1nb0w @ra1nb0w} openmaintainer
description         universal flash programming utility
long_description    utility for identifying, reading, writing, verifying and erasing flash chips.\
                    It is designed to flash BIOS/EFI/coreboot/firmware/optionROM images on \
                    mainboards, network/graphics/storage controller cards, and various other \
                    programmer devices.
homepage            https://www.flashrom.org/Flashrom
master_sites        https://download.flashrom.org/releases/
distname            ${name}-v${version}
use_bzip2           yes

checksums           rmd160  760f21c1580c910304583777304de664d6ae1aad \
                    sha256  a053234453ccd012e79f3443bdcc61625cf97b7fd7cb4cdd8bfbffbe8b149623 \
                    size    489782
revision            3

# revert the upstream patch
patchfiles-append   patch-ich_descriptors_tool.c.patch

depends_build       port:pkgconfig

depends_lib         port:libftdi1 \
                    port:libusb-compat

use_configure       no
build.args-append   CC=${configure.cc} \
                    CXX=${configure.cxx} \
                    CPP=${configure.cpp}

build.env-append    CONFIG_ENABLE_LIBPCI_PROGRAMMERS=0 \
                    CONFIG_GFXNVIDIA=0 \
                    CONFIG_NIC3COM=0 \
                    CONFIG_NICREALTEK=0 \
                    CONFIG_NICNATSEMI=0 \
                    CONFIG_NICINTEL=0 \
                    CONFIG_NICINTEL_SPI=0 \
                    CONFIG_NICINTEL_EEPROM=0 \
                    CONFIG_OGP_SPI=0 \
                    CONFIG_SATAMV=0 \
                    CONFIG_SATASII=0 \
                    CONFIG_DRKAISER=0 \
                    CONFIG_RAYER_SPI=0 \
                    CONFIG_INTERNAL=0 \
                    CONFIG_IT8212=0 \
                    CONFIG_ATAHPT=0 \
                    CONFIG_ATAVIA=0 \
                    CONFIG_INTERNAL_X86=0

destroot.env        {*}${build.env}

pre-build {
    reinplace "s|sbin|bin|g" ${worksrcpath}/Makefile
    reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/Makefile
}

test.run            yes
test.cmd            ./flashrom --version

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     ${name}-v(\\d+\\.\\d+(\\.\\d+)*)${extract.suffix}
