# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=portfile:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           conflicts_build 1.0
PortGroup           github 1.0

github.setup        radareorg radare2 6.0.2
github.tarball_from archive
revision            0
categories          devel
license             LGPL-3+
maintainers         {i0ntempest @i0ntempest} openmaintainer
description         Opensource tools to disasm, debug, analyze and manipulate binary files.
long_description    ${name} provides {*}${description}.
homepage            https://www.radare.org/

depends_build       port:pkgconfig

depends_lib         port:capstone \
                    port:zlib \
                    port:libzip
conflicts_build     ${name}

checksums           rmd160  ce090fee8448271022bfa060abdba3a4a1719c9e \
                    sha256  5879969ca502fff91ec255cd016e0b0840476f5edd490c75a64c0a1ffc8a7dca \
                    size    11446989

configure.args-append \
                    --with-syscapstone \
                    --with-syszip \
                    --with-compiler=clang

post-patch {
    # 5.7.8: r_fs library fails to build without -lzip. Check again in the next version.
    reinplace "s|LDFLAGS+=\$(SHLR)/grub/libgrubfs.a|LDFLAGS+=\$(SHLR)/grub/libgrubfs.a -lzip|g" ${worksrcpath}/libr/fs/Makefile
}

build.env-append    HOST_CC=${configure.cc}


variant openssl description {Use OpenSSL library} {
    depends_lib-append \
                    path:lib/libssl.dylib:openssl

    configure.args-append \
                    --with-openssl
}

default_variants    +openssl
