# -*- 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
PortGroup           perl5 1.0

name                hivex
version             1.3.24
revision            0
categories          devel
license             LGPL-2.1
maintainers         {makr @mohd-akram} openmaintainer

description         A self-contained library for reading and writing Windows \
                    Registry \"hive\" binary files.

long_description    {*}${description}

homepage            https://github.com/libguestfs/hivex

master_sites        https://download.libguestfs.org/hivex

checksums           rmd160  4235b67ed7a39a58050c10e2480ea502c947682f \
                    sha256  a52fa45cecc9a78adb2d28605d68261e4f1fd4514a778a5473013d2ccc8a193c \
                    size    741279

depends_run         port:perl${perl5.major}

depends_build-append    path:bin/pkg-config:pkgconfig \
                        port:gettext

depends_lib-append  port:libxml2 \
                    port:readline \
                    port:libiconv \
                    port:gettext-runtime

platform darwin {
    patchfiles-append   patch-lib-makefile.diff
}

post-patch {
    if {${perl5.variant} ne {}} {
        reinplace "s|#!/usr/bin/env perl|#!${perl5.bin}|" \
            ${worksrcpath}/regedit/hivexregedit
    }
}

configure.args      --disable-silent-rules \
                    --disable-ocaml \
                    --disable-python \
                    --disable-ruby \
                    --disable-perl

if {${perl5.variant} ne {}} {
    configure.perl          ${perl5.bin}
    configure.args-replace  --disable-perl --enable-perl
    depends_build-append    port:p${perl5.major}-io-stringy
}

build.args          INSTALLDIRS=vendor

post-destroot {
    if {${perl5.variant} ne {}} {
        delete ${destroot}[perl5.extract_config privlib]/${perl5.arch}/perllocal.pod
        delete ${destroot}${perl5.archlib}/auto/Win/Hivex/.packlist
    }
}
