# -*- 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                dtc
version             1.7.0
revision            0
categories          cross devel
maintainers         {adfernandes @adfernandes} openmaintainer
license             GPL-2+

description         Device tree compiler

long_description    Device Tree Compiler, dtc, takes as input a device-tree in a given format and outputs a \
                    device-tree in another format for booting kernels on embedded systems.  Typically, the \
                    input format is DTS, a human readable source format, and creates a DTB, or binary \
                    format as output.

homepage            https://git.kernel.org/pub/scm/utils/dtc/dtc.git
master_sites        ${homepage}/snapshot/

checksums           rmd160  0e8e5ddebc60381abbf0adc3147b58d0d5319ad2 \
                    sha256  70d9c156ec86d63de0f7bdae50540ffa492b25ec1d69491c7520845c860b9a62 \
                    size    211506

depends_build       port:gmake \
                    port:pkgconfig

post-patch {
    reinplace "s/-Werror//" ${worksrcpath}/Makefile
}

configure.cmd       echo

build.cmd           gmake V=1 NO_PYTHON=1 "PREFIX=${destroot}${prefix}" install

post-destroot       {
                        file delete -force "${destroot}${prefix}/var"
                        file mkdir "${destroot}${prefix}/share/doc/${name}"
                        xinstall -m 0644 {*}[glob "${worksrcpath}/Documentation/*.*"] "${destroot}${prefix}/share/doc/${name}"
                        system "install_name_tool -id ${prefix}/lib/libfdt.dylib.1 ${destroot}${prefix}/lib/libfdt.dylib.1"
                        foreach file [glob "${destroot}${prefix}/bin/fd*"] {
                            system "install_name_tool -change libfdt.dylib.1 ${prefix}/lib/libfdt.dylib.1 ${file}"
                        }
                    }

pre-activate {
    set checkfile ${prefix}/include/fdt.h
    if {[file exists $checkfile] && [registry_file_registered $checkfile] eq "qemu"} {
        registry_deactivate_composite qemu "" [dict create ports_nodepcheck 1]
    }
}

livecheck.type     regex
livecheck.url      "${homepage}"
livecheck.regex    "${name}-(\\d+(?:\\.\\d+)*)"
